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)
|
luasnip.lsp_expand(args.body)
|
||||||
vim.fn["vsnip#anonymous"](args.body)
|
end,
|
||||||
end,
|
},
|
||||||
},
|
window = {
|
||||||
mapping = {
|
completion = cmp.config.window.bordered(),
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
documentation = cmp.config.window.bordered(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
},
|
||||||
['<Tab>'] = function(fallback)
|
mapping = cmp.mapping.preset.insert({
|
||||||
if cmp.visible() then
|
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
||||||
cmp.select_next_item()
|
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
||||||
else
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
fallback()
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
end
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
end,
|
select = true,
|
||||||
['<S-Tab>'] = function(fallback)
|
},
|
||||||
if cmp.visible() then
|
['<C-n>'] = cmp.mapping(function(fallback)
|
||||||
cmp.select_prev_item()
|
if cmp.visible() then
|
||||||
else
|
cmp.select_next_item()
|
||||||
fallback()
|
elseif luasnip.expand_or_jumpable() then
|
||||||
end
|
luasnip.expand_or_jump()
|
||||||
end,
|
else
|
||||||
},
|
fallback()
|
||||||
sources = cmp.config.sources({
|
end
|
||||||
{ name = 'nvim_lsp' },
|
end, { 'i', 's' }),
|
||||||
{ name = 'vsnip' },
|
['<C-p>'] = cmp.mapping(function(fallback)
|
||||||
}, {
|
if cmp.visible() then
|
||||||
{ name = 'buffer' },
|
cmp.select_prev_item()
|
||||||
}),
|
elseif luasnip.jumpable(-1) then
|
||||||
})
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
fallback()
|
||||||
cmp.setup.cmdline('/', {
|
end
|
||||||
sources = {
|
end, { 'i', 's' }),
|
||||||
{ name = 'buffer' }
|
}),
|
||||||
}
|
sources = {
|
||||||
})
|
{ 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