From a71684c7f0819e658994d746faa8f484a44ac070 Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Fri, 25 Jul 2025 00:52:15 +0200 Subject: [PATCH] (neovim) add git, yaml, ansible and helm support; minor fixes --- .../global.markdownlint-cli2.yaml | 0 config/common/nvim/lsp/ansible.lua | 4 ++++ config/common/nvim/lsp/helm.lua | 4 ++++ config/common/nvim/lsp/yaml.lua | 4 ++++ config/common/nvim/lua/config/keymaps.lua | 18 +++++++++++------- config/common/nvim/lua/core/lsp.lua | 3 +++ config/common/nvim/lua/plugins/ansible.lua | 4 ++++ config/common/nvim/lua/plugins/linters.lua | 18 ++++++++++++------ config/common/nvim/lua/plugins/treesitter.lua | 8 +++++++- 9 files changed, 49 insertions(+), 14 deletions(-) rename config/common/nvim/{linters => cfg_linters}/global.markdownlint-cli2.yaml (100%) create mode 100644 config/common/nvim/lsp/ansible.lua create mode 100644 config/common/nvim/lsp/helm.lua create mode 100644 config/common/nvim/lsp/yaml.lua create mode 100644 config/common/nvim/lua/plugins/ansible.lua diff --git a/config/common/nvim/linters/global.markdownlint-cli2.yaml b/config/common/nvim/cfg_linters/global.markdownlint-cli2.yaml similarity index 100% rename from config/common/nvim/linters/global.markdownlint-cli2.yaml rename to config/common/nvim/cfg_linters/global.markdownlint-cli2.yaml diff --git a/config/common/nvim/lsp/ansible.lua b/config/common/nvim/lsp/ansible.lua new file mode 100644 index 0000000..2387fb3 --- /dev/null +++ b/config/common/nvim/lsp/ansible.lua @@ -0,0 +1,4 @@ +return { + cmd = { "ansible-language-server", "--stdio" }, + filetypes = { "yaml.ansible" }, +} diff --git a/config/common/nvim/lsp/helm.lua b/config/common/nvim/lsp/helm.lua new file mode 100644 index 0000000..9612796 --- /dev/null +++ b/config/common/nvim/lsp/helm.lua @@ -0,0 +1,4 @@ +return { + cmd = { "helm_ls", "serve" }, + filetypes = { "helm" }, +} diff --git a/config/common/nvim/lsp/yaml.lua b/config/common/nvim/lsp/yaml.lua new file mode 100644 index 0000000..95d0776 --- /dev/null +++ b/config/common/nvim/lsp/yaml.lua @@ -0,0 +1,4 @@ +return { + cmd = { "yaml-language-server", "--stdio" }, + filetypes = { "yaml" }, +} diff --git a/config/common/nvim/lua/config/keymaps.lua b/config/common/nvim/lua/config/keymaps.lua index f51d002..7516364 100644 --- a/config/common/nvim/lua/config/keymaps.lua +++ b/config/common/nvim/lua/config/keymaps.lua @@ -2,6 +2,10 @@ vim.g.mapleader = " " vim.g.maplocalleader = "\\" local map = vim.keymap.set +local nomap = vim.keymap.del + +nomap("n", "[D") +nomap("n", "]D") local diagnostic_goto = function(next, severity) 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", "", "I") map("i", "", "A") -map("n", "]d", diagnostic_goto(true), { desc = "Next 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(false, "ERROR"), { desc = "Prev Error" }) -map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" }) -map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) +map("n", "]d", diagnostic_goto(true), { desc = "next 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(false, "ERROR"), { desc = "prev error" }) +map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "next warning" }) +map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "prev warning" }) map("v", "/", "gc", { desc = "toggle comments", remap = true }) @@ -73,7 +77,7 @@ end, { desc = "grep", remap = true }) map("n", "hc", function() Snacks.picker.command_history() end, { desc = "commands", remap = true }) -map("n", "hn", "Noice", { desc = "notifications", remap = true }) +map("n", "hn", "messages", { desc = "notifications", remap = true }) map("n", "hs", function() Snacks.picker.search_history() end, { desc = "search", remap = true }) diff --git a/config/common/nvim/lua/core/lsp.lua b/config/common/nvim/lua/core/lsp.lua index 716b3da..e907b32 100644 --- a/config/common/nvim/lua/core/lsp.lua +++ b/config/common/nvim/lua/core/lsp.lua @@ -1,7 +1,10 @@ vim.lsp.enable({ + "ansible", + "helm", "lua", "terraform", "markdown", + "yaml", }) vim.diagnostic.config({ diff --git a/config/common/nvim/lua/plugins/ansible.lua b/config/common/nvim/lua/plugins/ansible.lua new file mode 100644 index 0000000..9c7190e --- /dev/null +++ b/config/common/nvim/lua/plugins/ansible.lua @@ -0,0 +1,4 @@ +return { + "mfussenegger/nvim-ansible", + ft = { "yaml.ansible" }, +} diff --git a/config/common/nvim/lua/plugins/linters.lua b/config/common/nvim/lua/plugins/linters.lua index 97636d9..d4b261c 100644 --- a/config/common/nvim/lua/plugins/linters.lua +++ b/config/common/nvim/lua/plugins/linters.lua @@ -6,14 +6,18 @@ return { build = ":MasonUpdate", opts = { ensure_installed = { + "ansible-language-server", + "ansible-lint", "lua-language-server", - "markdown-toc", "markdownlint-cli2", "marksman", "shfmt", "stylua", "terraform-ls", "tflint", + "yaml-language-server", + "yamlfix", + "yamllint", }, }, config = function(_, opts) @@ -54,12 +58,13 @@ return { markdown = { "markdownlint-cli2" }, terraform = { "terraform_validate" }, tf = { "terraform_validate" }, + yaml = { "yamllint" }, } local markdownlint = require("lint").linters["markdownlint-cli2"] markdownlint.args = { "--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" }, { @@ -84,11 +89,12 @@ return { terraform = { "terraform_fmt" }, tf = { "terraform_fmt" }, zsh = { "shfmt" }, + yaml = { "yamlfix" }, + }, + format_on_save = { + lsp_fallback = true, + async = false, }, - -- format_on_save = { - -- lsp_fallback = true, - -- async = false, - -- }, }) end, }, diff --git a/config/common/nvim/lua/plugins/treesitter.lua b/config/common/nvim/lua/plugins/treesitter.lua index 5034419..5099497 100644 --- a/config/common/nvim/lua/plugins/treesitter.lua +++ b/config/common/nvim/lua/plugins/treesitter.lua @@ -7,17 +7,23 @@ return { ensure_installed = { "bash", "diff", + "git_config", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore", "gotmpl", "hcl", "helm", "json", "lua", - "markdown", "markdown_inline", + "markdown", "python", "regex", "terraform", "vim", + "yaml", }, highlight = { enable = true }, indent = { enable = true },