Attach yamlls to yaml.ansible filetypes & show diagnostic source

similiar to lsp source
This commit is contained in:
Sonny Bakker 2025-02-14 09:28:41 +01:00
parent ee344af9f5
commit 5d15147130
3 changed files with 110 additions and 102 deletions

View file

@ -29,7 +29,6 @@ end
--enable some language servers with the additional completion capabilities
--offered by nvim-cmp
-- TODO: use `.join`?
local servers = {
{% for item in language_servers %}
{% if item.auto_setup and not loop.last %}
@ -61,33 +60,39 @@ local python_root_dir = function(fname)
util.path.dirname(fname)
end
nvim_lsp.ruff.setup({
nvim_lsp.ruff.setup {
on_attach = on_attach,
capabilities = capabilities,
root_dir = python_root_dir
})
}
nvim_lsp.pyright.setup({
nvim_lsp.pyright.setup {
settings = {
pyright = {
-- Using Ruff's import organizer
disableOrganizeImports = true,
},
},
})
}
nvim_lsp.html.setup({
nvim_lsp.html.setup {
on_attach = on_attach,
capabilities = capabilities,
filetypes = { 'html', 'htmldjango' },
})
}
{% endif %}
nvim_lsp.yamlls.setup {
on_attach = on_attach,
capabilities = capabilities,
filetypes = { 'yaml', 'yaml.ansible', 'yaml.docker-compose', 'yaml.gitlab' }
}
local cmp = require('cmp')
local luasnip = require('luasnip')
cmp.setup({
cmp.setup {
sources = {
{ name = 'nvim_lsp', },
{ name = 'buffer' },
@ -148,14 +153,15 @@ cmp.setup({
luasnip.lsp_expand(args.body)
end,
},
})
}
vim.diagnostic.config({
vim.diagnostic.config {
float = {
source = 'always',
border = border
suffix = function(diagnostic)
return (' %s | [%s]'):format(diagnostic.code, diagnostic.source)
end
},
})
}
local enable_formatting = os.getenv("ENABLE_FORMATTING", False)