neovim: upgrade to nvim-cmp from nvim-compe
This commit is contained in:
@@ -42,7 +42,7 @@ config =
|
|||||||
],
|
],
|
||||||
sepChar = "*",
|
sepChar = "*",
|
||||||
alignSep = "--",
|
alignSep = "--",
|
||||||
template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* " ++ sep ++ " <fn=1></fn>*mpd* -- *multicpu* " ++ sep ++ " *memory* " ++ sep ++ " *wlp0s20f3* " ++ sep ++ " *battery* " ++ sep ++ " <fn=1>\xf028</fn> <fc=" ++ green ++ ">*pamixer*%</fc> " ++ sep ++ " *date* - *time* *tray*"
|
template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* " ++ sep ++ " <fn=1></fn>*mpd* -- *multicpu* " ++ sep ++ " *memory* " ++ sep ++ " *wlp0s20f3* " ++ sep ++ " *battery* " ++ sep ++ " <fn=1>\xf028</fn> <fc=" ++ green ++ ">*pamixer*%</fc> " ++ sep ++ " *date* - *time* " ++ sep ++ "*tray*"
|
||||||
}
|
}
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
@@ -90,15 +90,15 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
config = {
|
config = {
|
||||||
geometry = "1x1-0";
|
geometry = "1x1-0";
|
||||||
max_geometry = "5x0";
|
max_geometry = "10x0";
|
||||||
window_type = "dock";
|
window_type = "dock";
|
||||||
sticky = true;
|
sticky = true;
|
||||||
scrollbars = "horizontal";
|
|
||||||
icon_size = 23;
|
icon_size = 23;
|
||||||
background = "#1d2021";
|
background = "#1d2021";
|
||||||
grow_gravity = "E";
|
|
||||||
icon_gravity = "E";
|
icon_gravity = "E";
|
||||||
|
grow_gravity = "E";
|
||||||
kludges = "force_icons_size";
|
kludges = "force_icons_size";
|
||||||
|
window_layer = "top";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
ccls
|
ccls
|
||||||
clang-tools
|
clang-tools
|
||||||
nodePackages.typescript-language-server
|
nodePackages.typescript-language-server
|
||||||
|
nodePackages.svelte-language-server
|
||||||
rnix-lsp
|
rnix-lsp
|
||||||
python3Packages.python-lsp-server
|
python3Packages.python-lsp-server
|
||||||
haskell-language-server
|
haskell-language-server
|
||||||
|
@@ -21,15 +21,23 @@
|
|||||||
vim-floaterm
|
vim-floaterm
|
||||||
vim-closetag
|
vim-closetag
|
||||||
nerdcommenter
|
nerdcommenter
|
||||||
nvim-compe
|
nvim-cmp
|
||||||
|
cmp_luasnip
|
||||||
|
cmp-nvim-lsp
|
||||||
|
cmp-path
|
||||||
|
cmp-calc
|
||||||
|
cmp-emoji
|
||||||
|
# cmp-look
|
||||||
|
cmp-buffer
|
||||||
nvim-lspconfig
|
nvim-lspconfig
|
||||||
barbar-nvim
|
barbar-nvim
|
||||||
presence-nvim
|
presence-nvim
|
||||||
nvim-web-devicons
|
nvim-web-devicons
|
||||||
nvim-tree-lua
|
nvim-tree-lua
|
||||||
vim-vsnip
|
luasnip
|
||||||
nvim-treesitter
|
nvim-treesitter
|
||||||
vim-latex-live-preview
|
vim-latex-live-preview
|
||||||
|
lspkind-nvim
|
||||||
# (gruvbox.overrideAttrs (oa: { patches = [ ./gruvbox.patch ]; }))
|
# (gruvbox.overrideAttrs (oa: { patches = [ ./gruvbox.patch ]; }))
|
||||||
base16-vim
|
base16-vim
|
||||||
];
|
];
|
||||||
|
@@ -7,9 +7,7 @@ local getvar = vim.api.nvim_get_var
|
|||||||
function hi(hi_var, hi_value)
|
function hi(hi_var, hi_value)
|
||||||
comm("hi " .. hi_var .. " " .. hi_value)
|
comm("hi " .. hi_var .. " " .. hi_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--SETTINGS
|
--SETTINGS
|
||||||
|
|
||||||
vim.o.cmdheight = 1
|
vim.o.cmdheight = 1
|
||||||
vim.o.modifiable = true
|
vim.o.modifiable = true
|
||||||
vim.o.cursorline = true
|
vim.o.cursorline = true
|
||||||
@@ -40,7 +38,6 @@ vim.o.clipboard = "unnamedplus"
|
|||||||
vim.o.completeopt = "menuone,noselect"
|
vim.o.completeopt = "menuone,noselect"
|
||||||
vim.o.cursorcolumn = true
|
vim.o.cursorcolumn = true
|
||||||
|
|
||||||
|
|
||||||
--KEYBINDS
|
--KEYBINDS
|
||||||
|
|
||||||
--Colemak-DH bind fuction for hjkl [mnei])
|
--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>r", ":NvimTreeRefresh<CR>", {noremap=true, silent=true})
|
||||||
bind('n', "<Space>f", ":NvimTreeFindFile<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"
|
vim.o.background="dark"
|
||||||
comm("colorscheme base16-tomorrow-night")
|
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})
|
buf_set_keymap('n', "<M-f>", "<cmd>lua vim.lsp.buf.formatting()<CR>", {silent=true, noremap=true})
|
||||||
end
|
end
|
||||||
|
|
||||||
require'compe'.setup {
|
local servers = { "ccls", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp" }
|
||||||
enabled = true;
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
autocomplete = true;
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
debug = false;
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
min_length = 1;
|
properties = {
|
||||||
preselect = 'enable';
|
'documentation',
|
||||||
throttle_time = 80;
|
'detail',
|
||||||
source_timeout = 200;
|
'additionalTextEdits',
|
||||||
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 t = function(str)
|
local nvimlsp = require('lspconfig')
|
||||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
for _, lsp in ipairs(servers) do
|
||||||
end
|
nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
|
||||||
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
|
|
||||||
end
|
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})
|
local luasnip = require 'luasnip'
|
||||||
bind("s", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
|
local cmp = require 'cmp'
|
||||||
bind("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
|
cmp.setup {
|
||||||
bind("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
|
snippet = {
|
||||||
bind("i", "<CR>", "compe#confirm('<CR>')", {expr = true, silent = true})
|
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")
|
comm("set shortmess+=c")
|
||||||
|
|
||||||
@@ -340,21 +362,6 @@ local statusline = {
|
|||||||
}
|
}
|
||||||
vim.o.statusline = table.concat(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"
|
vim.g.tex_flavor = "latex"
|
||||||
comm("set syntax=off")
|
comm("set syntax=off")
|
||||||
|
Reference in New Issue
Block a user