Adding a functional ansible lsp config
This commit is contained in:
parent
3b4f7e8c3e
commit
4ed0900c2b
@ -1,7 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"stevearc/conform.nvim",
|
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
@ -15,10 +14,6 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
require("conform").setup({
|
|
||||||
formatters_by_ft = {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
local cmp_lsp = require("cmp_nvim_lsp")
|
local cmp_lsp = require("cmp_nvim_lsp")
|
||||||
local capabilities = vim.tbl_deep_extend(
|
local capabilities = vim.tbl_deep_extend(
|
||||||
@ -29,13 +24,78 @@ return {
|
|||||||
|
|
||||||
require("fidget").setup({})
|
require("fidget").setup({})
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
-- require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
-- handlers = {
|
ensure_installed = {
|
||||||
-- function(server_name) -- default handler (optional)
|
"lua_ls",
|
||||||
-- require("lspconfig")[server_name].setup {
|
"ansiblels",
|
||||||
-- capabilities = capabilities
|
},
|
||||||
-- }
|
handlers = {
|
||||||
-- end,
|
function(server_name) -- default handler (optional)
|
||||||
|
|
||||||
|
require("lspconfig")[server_name].setup {
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
|
||||||
|
["ansiblels"] = function()
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
lspconfig["ansiblels"].setup({
|
||||||
|
cmd = { 'ansible-language-server', '--stdio' },
|
||||||
|
settings = {
|
||||||
|
ansible = {
|
||||||
|
python = { interpreterPath = 'python' },
|
||||||
|
ansible = { path = 'ansible' },
|
||||||
|
executionEnvironment = { enabled = false },
|
||||||
|
validation = {
|
||||||
|
enabled = false,
|
||||||
|
-- lint = { enabled = true, path = 'ansible-lint' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filetypes = { 'yaml', 'yml', 'ansible' },
|
||||||
|
root_dir = lspconfig.util.root_pattern("roles", "playbooks"),
|
||||||
|
single_file_support = false,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
|
||||||
|
|
||||||
|
["lua_ls"] = function()
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
lspconfig.lua_ls.setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim", "it", "describe", "before_each", "after_each" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||||
|
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' }, -- For luasnip users.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
-- update_in_insert = true,
|
-- update_in_insert = true,
|
||||||
@ -49,4 +109,4 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user