Add neovim configuration files
This commit is contained in:
parent
6cd67e88ad
commit
74a974be5e
25 changed files with 8576 additions and 15 deletions
55
templates/nvim/lua/lsp.lua.j2
Normal file
55
templates/nvim/lua/lsp.lua.j2
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
-- {{ 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)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
-- enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- mappings
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
--see `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
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', }
|
||||
|
||||
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
|
||||
util.path.dirname(fname)
|
||||
end
|
||||
})
|
||||
|
||||
nvim_lsp.html.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { 'html', 'htmldjango' },
|
||||
})
|
||||
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue