mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-24 16:28:22 -05:00
neovim: breaking change in nvim-cmp config
nvim-cmp now uses floating window instead of pumsible. See https://github.com/hrsh7th/nvim-cmp/issues/231
This commit is contained in:
parent
4508f2a819
commit
c9941850a2
@ -278,10 +278,35 @@ local function highlight_lsp()
|
||||
hi('LspReferenceRead', c.fg, c.grey_bright, '', '')
|
||||
hi('LspReferenceWrite', c.fg, c.grey_bright, '', '')
|
||||
vim.api.nvim_command('hi! link LspCodeLens Comment')
|
||||
|
||||
-- Theses are for neovim 0.6
|
||||
vim.api.nvim_command('hi! link DiagnosticVirtualTextWarn LspDiagnosticsVirtualTextWarning')
|
||||
vim.api.nvim_command('hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning')
|
||||
vim.api.nvim_command('hi! link DiagnosticFloatingWarn LspDiagnosticsFloatingWarning')
|
||||
vim.api.nvim_command('hi! link DiagnosticSignWarn LspDiagnosticsSignWarning')
|
||||
vim.api.nvim_command('hi! link DiagnosticVirtualTextError LspDiagnosticsVirtualTextError')
|
||||
vim.api.nvim_command('hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError')
|
||||
vim.api.nvim_command('hi! link DiagnosticFloatingError LspDiagnosticsFloatingError')
|
||||
vim.api.nvim_command('hi! link DiagnosticSignError LspDiagnosticsSignError')
|
||||
vim.api.nvim_command('hi! link DiagnosticVirtualTextInfo LspDiagnosticsVirtualTextInformation')
|
||||
vim.api.nvim_command('hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation')
|
||||
vim.api.nvim_command('hi! link DiagnosticFloatingInfo LspDiagnosticsFloatingInformation')
|
||||
vim.api.nvim_command('hi! link DiagnosticSignInfo LspDiagnosticsSignInformation')
|
||||
vim.api.nvim_command('hi! link DiagnosticVirtualTextHint LspDiagnosticsVirtualTextHint')
|
||||
vim.api.nvim_command('hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint')
|
||||
vim.api.nvim_command('hi! link DiagnosticFloatingHint LspDiagnosticsFloatingHint')
|
||||
vim.api.nvim_command('hi! link DiagnosticSignHint LspDiagnosticsSignHint')
|
||||
end
|
||||
|
||||
-- Specify groups for plugins
|
||||
local function highlight_plugins()
|
||||
-- nvim-cmp (experimental custom menu)
|
||||
hi('CmpItemAbbr', c.fg, '', '', '')
|
||||
hi('CmpItemAbbrMatch', c.yellow, '', '', '')
|
||||
hi('CmpItemAbbrMatchFuzzy', c.yellow, '', '', '')
|
||||
hi('CmpItemKind', c.fg, '', '', '')
|
||||
hi('CmpItemMenu', c.fg, '', '', '')
|
||||
|
||||
-- Gitsigns
|
||||
hi('GitSignsAddNr' , c.green , '', '', '')
|
||||
hi('GitSignsChangeNr', c.yellow, '', '', '')
|
||||
|
@ -5,11 +5,12 @@ function M.cmp_conf()
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
local has_words_before = function()
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
return not vim.api.nvim_get_current_line():sub(1, cursor[2]):match('^%s$')
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
|
||||
end
|
||||
|
||||
cmp.setup {
|
||||
experimental = {custom_menu = true}, -- Use custom highlightng for the floating completion menu
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
local lspkind_icons = {
|
||||
@ -72,33 +73,35 @@ function M.cmp_conf()
|
||||
-- Change choice nodes for luasnip
|
||||
['<C-h>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.choice_active() then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-prev-choice', true, true, true), '', true)
|
||||
luasnip.change_choice(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {'i', 's'}),
|
||||
['<C-l>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.choice_active() then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-next-choice', true, true, true), '', true)
|
||||
luasnip.change_choice(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {'i', 's'}),
|
||||
-- supertab-like mapping
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n', true)
|
||||
elseif has_words_before() and luasnip.expand_or_jumpable() then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '', true)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {'i', 's'}),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n', true)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '', true)
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
@ -1,7 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# TODO: consider forking 'kabouzeid/nvim-lspinstall' or 'anott03/nvim-lspinstall'
|
||||
# instead of running scripts
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage:"
|
||||
printf " - %s server_name: install specified server\n" "$0"
|
||||
|
Loading…
Reference in New Issue
Block a user