(neovim) add git, yaml, ansible and helm support; minor fixes

This commit is contained in:
Bartek Stalewski 2025-07-25 00:52:15 +02:00
parent 79d83fd921
commit a71684c7f0
No known key found for this signature in database
9 changed files with 49 additions and 14 deletions

View file

@ -0,0 +1,4 @@
return {
cmd = { "ansible-language-server", "--stdio" },
filetypes = { "yaml.ansible" },
}

View file

@ -0,0 +1,4 @@
return {
cmd = { "helm_ls", "serve" },
filetypes = { "helm" },
}

View file

@ -0,0 +1,4 @@
return {
cmd = { "yaml-language-server", "--stdio" },
filetypes = { "yaml" },
}

View file

@ -2,6 +2,10 @@ vim.g.mapleader = " "
vim.g.maplocalleader = "\\" vim.g.maplocalleader = "\\"
local map = vim.keymap.set local map = vim.keymap.set
local nomap = vim.keymap.del
nomap("n", "[D")
nomap("n", "]D")
local diagnostic_goto = function(next, severity) local diagnostic_goto = function(next, severity)
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
@ -19,12 +23,12 @@ end, { expr = true, desc = "Escape and Clear hlsearch" })
map("i", "<C-a>", "<esc>I") map("i", "<C-a>", "<esc>I")
map("i", "<C-e>", "<esc>A") map("i", "<C-e>", "<esc>A")
map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" }) map("n", "]d", diagnostic_goto(true), { desc = "next diagnostic" })
map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" }) map("n", "[d", diagnostic_goto(false), { desc = "prev diagnostic" })
map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" }) map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "next error" })
map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" }) map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "prev error" })
map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" }) map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "next warning" })
map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "prev warning" })
map("v", "<leader>/", "gc", { desc = "toggle comments", remap = true }) map("v", "<leader>/", "gc", { desc = "toggle comments", remap = true })
@ -73,7 +77,7 @@ end, { desc = "grep", remap = true })
map("n", "<leader>hc", function() map("n", "<leader>hc", function()
Snacks.picker.command_history() Snacks.picker.command_history()
end, { desc = "commands", remap = true }) end, { desc = "commands", remap = true })
map("n", "<leader>hn", "<cmd>Noice<CR>", { desc = "notifications", remap = true }) map("n", "<leader>hn", "<cmd>messages<CR>", { desc = "notifications", remap = true })
map("n", "<leader>hs", function() map("n", "<leader>hs", function()
Snacks.picker.search_history() Snacks.picker.search_history()
end, { desc = "search", remap = true }) end, { desc = "search", remap = true })

View file

@ -1,7 +1,10 @@
vim.lsp.enable({ vim.lsp.enable({
"ansible",
"helm",
"lua", "lua",
"terraform", "terraform",
"markdown", "markdown",
"yaml",
}) })
vim.diagnostic.config({ vim.diagnostic.config({

View file

@ -0,0 +1,4 @@
return {
"mfussenegger/nvim-ansible",
ft = { "yaml.ansible" },
}

View file

@ -6,14 +6,18 @@ return {
build = ":MasonUpdate", build = ":MasonUpdate",
opts = { opts = {
ensure_installed = { ensure_installed = {
"ansible-language-server",
"ansible-lint",
"lua-language-server", "lua-language-server",
"markdown-toc",
"markdownlint-cli2", "markdownlint-cli2",
"marksman", "marksman",
"shfmt", "shfmt",
"stylua", "stylua",
"terraform-ls", "terraform-ls",
"tflint", "tflint",
"yaml-language-server",
"yamlfix",
"yamllint",
}, },
}, },
config = function(_, opts) config = function(_, opts)
@ -54,12 +58,13 @@ return {
markdown = { "markdownlint-cli2" }, markdown = { "markdownlint-cli2" },
terraform = { "terraform_validate" }, terraform = { "terraform_validate" },
tf = { "terraform_validate" }, tf = { "terraform_validate" },
yaml = { "yamllint" },
} }
local markdownlint = require("lint").linters["markdownlint-cli2"] local markdownlint = require("lint").linters["markdownlint-cli2"]
markdownlint.args = { markdownlint.args = {
"--config", "--config",
"/Users/f/.config/nvim-ftpd/linters/global.markdownlint-cli2.yaml", vim.fn.stdpath("config") .. "/cfg_linters/global.markdownlint-cli2.yaml",
} }
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
@ -84,11 +89,12 @@ return {
terraform = { "terraform_fmt" }, terraform = { "terraform_fmt" },
tf = { "terraform_fmt" }, tf = { "terraform_fmt" },
zsh = { "shfmt" }, zsh = { "shfmt" },
yaml = { "yamlfix" },
},
format_on_save = {
lsp_fallback = true,
async = false,
}, },
-- format_on_save = {
-- lsp_fallback = true,
-- async = false,
-- },
}) })
end, end,
}, },

View file

@ -7,17 +7,23 @@ return {
ensure_installed = { ensure_installed = {
"bash", "bash",
"diff", "diff",
"git_config",
"git_rebase",
"gitattributes",
"gitcommit",
"gitignore",
"gotmpl", "gotmpl",
"hcl", "hcl",
"helm", "helm",
"json", "json",
"lua", "lua",
"markdown",
"markdown_inline", "markdown_inline",
"markdown",
"python", "python",
"regex", "regex",
"terraform", "terraform",
"vim", "vim",
"yaml",
}, },
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },