Add Luasnip
This commit is contained in:
parent
9881f4134b
commit
82c346506d
3 changed files with 46 additions and 9 deletions
|
|
@ -18,7 +18,7 @@
|
|||
dest: '{{ xdg_data_dir }}/nvim/site/pack/default/start/{{ item.name }}'
|
||||
update: true
|
||||
version: '{{ item.version|default("HEAD") }}'
|
||||
loop: '{{ vim_plugins }}'
|
||||
loop: '{{ neovim_plugins }}'
|
||||
|
||||
- name: install pynvim package
|
||||
pip:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
--add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
--use an on_attach function to only map the following keys
|
||||
--after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
|
|
@ -24,12 +20,17 @@ local on_attach = function(client, bufnr)
|
|||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
end
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
--enable some language servers with the additional completion capabilities
|
||||
--offered by nvim-cmp
|
||||
local servers = { 'ansiblels', 'yamlls', 'cssls', 'jsonls', 'tsserver', }
|
||||
|
||||
--add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
|
|
@ -37,13 +38,13 @@ for _, lsp in ipairs(servers) do
|
|||
}
|
||||
end
|
||||
|
||||
local util = require("lspconfig/util")
|
||||
local util = require('lspconfig/util')
|
||||
|
||||
nvim_lsp.pyright.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern(".git", "setup.cfg", "requirements")(fname) or
|
||||
return util.root_pattern('.git', 'setup.cfg', 'requirements')(fname) or
|
||||
util.path.dirname(fname)
|
||||
end
|
||||
})
|
||||
|
|
@ -53,3 +54,38 @@ nvim_lsp.html.setup({
|
|||
capabilities = capabilities,
|
||||
filetypes = { 'html', 'htmldjango' },
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['S-<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
}),
|
||||
sources = {
|
||||
{ names = 'nvim_lsp', },
|
||||
{ names = 'luasnip', }, -- TODO: add snippets
|
||||
},
|
||||
})
|
||||
|
|
|
|||
3
vars.yml
3
vars.yml
|
|
@ -39,7 +39,7 @@ public_dotfiles_repo: 'git@git.fudiggity.nl:sonny/dotfiles.git'
|
|||
githook_repo: 'git@git.fudiggity.nl:sonny/git-hooks.git'
|
||||
public_githook_repo: 'git@git.fudiggity.nl:sonny/git-hooks.git'
|
||||
|
||||
vim_plugins:
|
||||
neovim_plugins:
|
||||
- { url: 'https://github.com/preservim/nerdtree', name: 'nerdtree' }
|
||||
- { url: 'https://github.com/sheerun/vim-polyglot', name: 'vim-polygot' }
|
||||
- { url: 'https://github.com/neovim/nvim-lspconfig', name: 'nvim-lspconfig' }
|
||||
|
|
@ -56,6 +56,7 @@ vim_plugins:
|
|||
name: 'telescope.nvim',
|
||||
version: '0.1.x',
|
||||
}
|
||||
- { url: 'https://github.com/L3MON4D3/LuaSnip', name: 'luasnip', version: 'v1.0.0' }
|
||||
|
||||
neovim_node_packages:
|
||||
- typescript
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue