add ansible lsp configuration
This commit is contained in:
57
lua/config/lsp/ansible.lua
Normal file
57
lua/config/lsp/ansible.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
local ok, mason_lspconfig, mason_tool_installer, lspconfig, conform, lint = pcall(function()
|
||||
return require("mason-lspconfig"),
|
||||
require("mason-tool-installer"),
|
||||
require("lspconfig"),
|
||||
require("conform"),
|
||||
require("lint")
|
||||
end)
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = { "ansiblels" },
|
||||
})
|
||||
|
||||
lspconfig.ansiblels.setup({
|
||||
capabilities = require("config/lsp/lsp-capabilities"),
|
||||
on_attach = require("config/lsp/lsp-attach"),
|
||||
})
|
||||
|
||||
mason_tool_installer.setup({
|
||||
ensure_installed = { "ansible-lint" },
|
||||
})
|
||||
|
||||
conform.setup({
|
||||
formatters_by_ft = {
|
||||
yml = { "ansible-lint" },
|
||||
},
|
||||
format_on_save = {
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = true,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<leader>lf", function()
|
||||
conform.format({
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = true,
|
||||
})
|
||||
end, { desc = "Format" })
|
||||
|
||||
lint.linters_by_ft = {
|
||||
yml = { "ansible-lint" },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
callback = function()
|
||||
lint.try_lint()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>ll", function()
|
||||
lint.try_lint()
|
||||
end, { desc = "Lint" })
|
||||
@@ -43,7 +43,7 @@ vim.keymap.set({ "n", "v" }, "<leader>lf", function()
|
||||
end, { desc = "Format" })
|
||||
|
||||
lint.linters_by_ft = {
|
||||
lua = { "shellcheck" },
|
||||
sh = { "shellcheck" },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
|
||||
@@ -49,7 +49,7 @@ vim.keymap.set({ "n", "v" }, "<leader>lf", function()
|
||||
end, { desc = "Format" })
|
||||
|
||||
lint.linters_by_ft = {
|
||||
phpcs = { "phpcs" },
|
||||
php = { "phpcs" },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
|
||||
Reference in New Issue
Block a user