|
|
|
|
@@ -7,9 +7,7 @@ local getvar = vim.api.nvim_get_var
|
|
|
|
|
function hi(hi_var, hi_value)
|
|
|
|
|
comm("hi " .. hi_var .. " " .. hi_value)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--SETTINGS
|
|
|
|
|
|
|
|
|
|
vim.o.cmdheight = 1
|
|
|
|
|
vim.o.modifiable = true
|
|
|
|
|
vim.o.cursorline = true
|
|
|
|
|
@@ -40,7 +38,6 @@ vim.o.clipboard = "unnamedplus"
|
|
|
|
|
vim.o.completeopt = "menuone,noselect"
|
|
|
|
|
vim.o.cursorcolumn = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--KEYBINDS
|
|
|
|
|
|
|
|
|
|
--Colemak-DH bind fuction for hjkl [mnei])
|
|
|
|
|
@@ -140,10 +137,6 @@ bind('n', "<M-o>", ":NvimTreeToggle<CR>", {noremap=true, silent=true})
|
|
|
|
|
bind('n', "<Space>r", ":NvimTreeRefresh<CR>", {noremap=true, silent=true})
|
|
|
|
|
bind('n', "<Space>f", ":NvimTreeFindFile<CR>", {noremap=true, silent=true})
|
|
|
|
|
|
|
|
|
|
--theme
|
|
|
|
|
--im.g.gruvbox_italic=1
|
|
|
|
|
--vim.g.gruvbox_contrast_dark="hard"
|
|
|
|
|
--vim.g.gruvbox_contrast_light="hard"
|
|
|
|
|
vim.o.background="dark"
|
|
|
|
|
comm("colorscheme base16-tomorrow-night")
|
|
|
|
|
|
|
|
|
|
@@ -216,75 +209,104 @@ local on_attach = function(client, bufnr)
|
|
|
|
|
buf_set_keymap('n', "<M-f>", "<cmd>lua vim.lsp.buf.formatting()<CR>", {silent=true, noremap=true})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
require'compe'.setup {
|
|
|
|
|
enabled = true;
|
|
|
|
|
autocomplete = true;
|
|
|
|
|
debug = false;
|
|
|
|
|
min_length = 1;
|
|
|
|
|
preselect = 'enable';
|
|
|
|
|
throttle_time = 80;
|
|
|
|
|
source_timeout = 200;
|
|
|
|
|
incomplete_delay = 400;
|
|
|
|
|
max_abbr_width = 100;
|
|
|
|
|
max_kind_width = 100;
|
|
|
|
|
max_menu_width = 100;
|
|
|
|
|
documentation = true;
|
|
|
|
|
|
|
|
|
|
source = {
|
|
|
|
|
path = true;
|
|
|
|
|
buffer = true;
|
|
|
|
|
nvim_lsp = true;
|
|
|
|
|
calc = true;
|
|
|
|
|
spell = true;
|
|
|
|
|
treesitter = true;
|
|
|
|
|
nvim_lua = true;
|
|
|
|
|
vsnip = true;
|
|
|
|
|
};
|
|
|
|
|
local servers = { "ccls", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp" }
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
|
|
|
properties = {
|
|
|
|
|
'documentation',
|
|
|
|
|
'detail',
|
|
|
|
|
'additionalTextEdits',
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local t = function(str)
|
|
|
|
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
|
|
|
|
end
|
|
|
|
|
local check_back_space = function()
|
|
|
|
|
local col = vim.fn.col('.') - 1
|
|
|
|
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
local nvimlsp = require('lspconfig')
|
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
|
nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
vim.g.vsnip_snippet_dir = "/home/natto/.vsnip"
|
|
|
|
|
-- Use (s-)tab to:
|
|
|
|
|
--- move to prev/next item in completion menuone
|
|
|
|
|
--- jump to prev/next snippet's placeholder
|
|
|
|
|
_G.tab_complete = function()
|
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
|
return t "<C-n>"
|
|
|
|
|
elseif vim.fn.call("vsnip#available", {1}) == 1 then
|
|
|
|
|
return t "<Plug>(vsnip-expand-or-jump)"
|
|
|
|
|
elseif check_back_space() then
|
|
|
|
|
return t "<Tab>"
|
|
|
|
|
else
|
|
|
|
|
return vim.fn['compe#complete']()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
_G.s_tab_complete = function()
|
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
|
return t "<C-e>"
|
|
|
|
|
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
|
|
|
|
|
return t "<Plug>(vsnip-jump-prev)"
|
|
|
|
|
else
|
|
|
|
|
-- If <S-Tab> is not working in your terminal, change it to <C-h>
|
|
|
|
|
return t "<S-Tab>"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
bind("i", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
|
|
|
|
|
bind("s", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
|
|
|
|
|
bind("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
|
|
|
|
|
bind("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
|
|
|
|
|
bind("i", "<CR>", "compe#confirm('<CR>')", {expr = true, silent = true})
|
|
|
|
|
local luasnip = require 'luasnip'
|
|
|
|
|
local cmp = require 'cmp'
|
|
|
|
|
cmp.setup {
|
|
|
|
|
snippet = {
|
|
|
|
|
expand = function(args)
|
|
|
|
|
require('luasnip').lsp_expand(args.body)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
mapping = {
|
|
|
|
|
['<C-e>'] = cmp.mapping.select_prev_item(),
|
|
|
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
|
|
|
['<C-p>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
|
|
|
['<C-q>'] = cmp.mapping.close(),
|
|
|
|
|
['<CR>'] = cmp.mapping.confirm {
|
|
|
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
|
|
|
select = true,
|
|
|
|
|
},
|
|
|
|
|
['<Tab>'] = function(fallback)
|
|
|
|
|
if cmp.visible() then
|
|
|
|
|
cmp.select_next_item()
|
|
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
|
luasnip.expand_or_jump()
|
|
|
|
|
else
|
|
|
|
|
fallback()
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
['<S-Tab>'] = function(fallback)
|
|
|
|
|
if cmp.visible() then
|
|
|
|
|
cmp.select_prev_item()
|
|
|
|
|
elseif luasnip.jumpable(-1) then
|
|
|
|
|
luasnip.jump(-1)
|
|
|
|
|
else
|
|
|
|
|
fallback()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
},
|
|
|
|
|
sources = {
|
|
|
|
|
{ name = 'nvim_lsp'},
|
|
|
|
|
{ name = 'path'},
|
|
|
|
|
{ name = 'nvim_lua'},
|
|
|
|
|
{ name = 'luasnip'},
|
|
|
|
|
{ name = 'calc'},
|
|
|
|
|
{ name = 'emoji'},
|
|
|
|
|
{ name = 'buffer'},
|
|
|
|
|
{ name = 'look'},
|
|
|
|
|
},
|
|
|
|
|
formatting = {
|
|
|
|
|
format = require('lspkind').cmp_format({
|
|
|
|
|
with_text = true,
|
|
|
|
|
menu = ({
|
|
|
|
|
buffer = "[Buffer]",
|
|
|
|
|
nvim_lsp = "[LSP]",
|
|
|
|
|
luasnip = "[LuaSnip]",
|
|
|
|
|
nvim_lua = "[Lua]",
|
|
|
|
|
latex_symbols = "[Latex]",
|
|
|
|
|
})
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
cmp.setup.cmdline('/', {
|
|
|
|
|
sources = {
|
|
|
|
|
{ name = 'buffer' }
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
|
|
|
cmp.setup.cmdline(':', {
|
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
|
{ name = 'path' }
|
|
|
|
|
}, {
|
|
|
|
|
{ name = 'cmdline' }
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
--bind("i", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
|
|
|
|
|
--bind("s", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
|
|
|
|
|
--bind("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
|
|
|
|
|
--bind("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
|
|
|
|
|
--bind("i", "<CR>", "compe#confirm('<CR>')", {expr = true, silent = true})
|
|
|
|
|
|
|
|
|
|
comm("set shortmess+=c")
|
|
|
|
|
|
|
|
|
|
@@ -340,21 +362,6 @@ local statusline = {
|
|
|
|
|
}
|
|
|
|
|
vim.o.statusline = table.concat(statusline)
|
|
|
|
|
|
|
|
|
|
local servers = { "ccls", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp" }
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
|
|
|
properties = {
|
|
|
|
|
'documentation',
|
|
|
|
|
'detail',
|
|
|
|
|
'additionalTextEdits',
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local nvimlsp = require('lspconfig')
|
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
|
nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
vim.g.tex_flavor = "latex"
|
|
|
|
|
comm("set syntax=off")
|
|
|
|
|
|