Simplify LSP and remap a few LSP keybindings
parent
3f17c0ca75
commit
0f8b79f10a
@ -1,56 +1,47 @@
|
|||||||
-- TODO: Improve docs
|
-- luasnip setup
|
||||||
-- Setup nvim-cmp.
|
local luasnip = require 'luasnip'
|
||||||
local cmp = require'cmp'
|
|
||||||
|
|
||||||
-- Ensure vsnip is installed
|
-- nvim-cmp setup
|
||||||
require'cmp_vsnip'
|
local cmp = require 'cmp'
|
||||||
|
cmp.setup {
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn["vsnip#anonymous"](args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = {
|
window = {
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
completion = cmp.config.window.bordered(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
documentation = cmp.config.window.bordered(),
|
||||||
['<Tab>'] = function(fallback)
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
['<C-n>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end,
|
end, { 'i', 's' }),
|
||||||
['<S-Tab>'] = function(fallback)
|
['<C-p>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end,
|
end, { 'i', 's' }),
|
||||||
},
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'vsnip' },
|
|
||||||
}, {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
}),
|
}),
|
||||||
})
|
|
||||||
|
|
||||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
|
||||||
cmp.setup.cmdline('/', {
|
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'buffer' }
|
{ name = 'nvim_lsp' },
|
||||||
}
|
--{ name = 'luasnip' },
|
||||||
})
|
},
|
||||||
|
}
|
||||||
-- 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' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return { cmp = cmp }
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
require('treesitter-context').setup{
|
||||||
|
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
|
||||||
|
throttle = true, -- Throttles plugin updates (may improve performance)
|
||||||
|
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
|
||||||
|
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
|
||||||
|
-- For all filetypes
|
||||||
|
default = {
|
||||||
|
'class',
|
||||||
|
'function',
|
||||||
|
'method',
|
||||||
|
'for',
|
||||||
|
'while',
|
||||||
|
-- 'if',
|
||||||
|
-- 'switch',
|
||||||
|
-- 'case',
|
||||||
|
},
|
||||||
|
rust = {
|
||||||
|
'loop_expression',
|
||||||
|
'impl_item',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue