diff --git a/modules/home-manager/cli/neovim/default.nix b/modules/home-manager/cli/neovim/default.nix index f6556e9..280936a 100644 --- a/modules/home-manager/cli/neovim/default.nix +++ b/modules/home-manager/cli/neovim/default.nix @@ -10,16 +10,6 @@ let url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; }; - fromGitHub = rev: ref: repo: - pkgs.vimUtils.buildVimPlugin { - pname = "${pkgs.lib.strings.sanitizeDerivationName repo}"; - version = ref; - src = builtins.fetchGit { - url = "https://github.com/${repo}.git"; - ref = ref; - rev = rev; - }; - }; in { options.modules.cli.neovim = { @@ -54,7 +44,6 @@ in # Formatters nixfmt-rfc-style shfmt - yamlfmt ]; extraLuaConfig = (builtins.readFile ./files/options.lua); plugins = with pkgs.vimPlugins; [ @@ -80,11 +69,6 @@ in cmp-path cmp-cmdline cmp_luasnip - { - plugin = conform-nvim; - type = "lua"; - config = (builtins.readFile ./files/conform.lua); - } { plugin = fzf-lua; type = "lua"; @@ -197,15 +181,6 @@ in type = "lua"; config = ( builtins.readFile ./files/whichkey.lua ); } -# yaml companion - { - plugin = ( fromGitHub - "131b0d67bd2e0f1a02e0daf2f3460482221ce3c0" - "main" - "someone-stole-my-name/yaml-companion.nvim" - ); - type = "lua"; - } vim-helm ]; }; diff --git a/modules/home-manager/cli/neovim/files/conform.lua b/modules/home-manager/cli/neovim/files/conform.lua deleted file mode 100644 index ff3d6d8..0000000 --- a/modules/home-manager/cli/neovim/files/conform.lua +++ /dev/null @@ -1,11 +0,0 @@ -require("conform").setup({ - format_on_save = { - -- These options will be passed to conform.format() - timeout_ms = 500, - lsp_format = "never", - }, - formatters_by_ft = { - yaml = {"yamlfmt"}, - ["_"] = { "trim_whitespace" }, - } -}) diff --git a/modules/home-manager/cli/neovim/files/fzf-lua.lua b/modules/home-manager/cli/neovim/files/fzf-lua.lua index 7282715..7cc193c 100644 --- a/modules/home-manager/cli/neovim/files/fzf-lua.lua +++ b/modules/home-manager/cli/neovim/files/fzf-lua.lua @@ -13,14 +13,6 @@ require('fzf-lua').setup({ } }) --- Register fzf-lua as vim.ui.select handler -require('fzf-lua').register_ui_select({ - prompt = 'Make a selection:', - format_item = function(item) - return "-> " .. tostring(item) - end, -}) - vim.keymap.set('n', 'fb', function() require('fzf-lua').buffers() end, {desc='open [b]uffers'}) vim.keymap.set('n', 'ff', function() require('fzf-lua').files() end, {desc='[r]esume last command'}) vim.keymap.set('n', 'fr', function() require('fzf-lua').files() end, {desc='[f]iles'}) diff --git a/modules/home-manager/cli/neovim/files/lspconfig.lua b/modules/home-manager/cli/neovim/files/lspconfig.lua index a7df681..ba64719 100644 --- a/modules/home-manager/cli/neovim/files/lspconfig.lua +++ b/modules/home-manager/cli/neovim/files/lspconfig.lua @@ -1,6 +1,5 @@ local lspconfig = require('lspconfig') local capabilities = require("cmp_nvim_lsp").default_capabilities() -require("yaml-companion").open_ui_select() lspconfig.bashls.setup { capabilities = capabilities, @@ -14,66 +13,20 @@ lspconfig.eslint.setup{ capabilities = capabilities, } --- YAML variables and Helm LS (quite big!) -local schemas = {} - -local kubernetes = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.29.6-standalone-strict/all.json" -local flux2 = "https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/refs/heads/main/all.json" -local gitlab = "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json" -local taskfile = "https://taskfile.dev/schema.json" -local podmonitor = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/monitoring.coreos.com/podmonitor_v1.json" -local servicemonitor = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/monitoring.coreos.com/servicemonitor_v1.json" -local prometheus = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/monitoring.coreos.com/prometheus_v1.json" -local ingress = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.30.1/ingress-networking-v1.json" -local lefthook = "https://json.schemastore.org/lefthook.json" -local github = "https://json.schemastore.org/github-workflow.json" - -schemas[kubernetes] = { - "templates/*deployment.yaml", - "templates/*service.yaml", - "templates/*secret.yaml", - "templates/*configmap.yaml", - "templates/*daemonset.yaml", - "templates/*replicaset.yaml", - "templates/*persistentvolume.yaml", - "templates/*persistentvolumeclaim.yaml", - "templates/*serviceaccount.yaml", - "templates/*role.yaml", - "templates/*rolebinding.yaml", - "templates/*clusterrole.yaml", - "templates/*clusterrolebinding.yaml", - "templates/*job*.yaml", -} -schemas[podmonitor] = "templates/*podmonitor*" -schemas[servicemonitor] = "templates/*servicemonitor*" -schemas[ingress] = "templates/*ingress*" - -lspconfig.helm_ls.setup { - capabilities = capabilities, - settings = { - ['helm-ls'] = { - yamlls = { - enabled = true, - enabledForFilesGlob = "*.{yaml,yml}", - diagnosticsLimit = 50, - showDiagnosticsDirectly = false, - path = "yaml-language-server", - config = { - schemas = schemas, - completion = true, - hover = true, - } - } +lspconfig.helm_ls.setup{ + capabilities = capabilities, + settings = { + ['helm-ls'] = { + logLevel = "info", + valuesFiles = { + mainValuesFile = "values.yaml", + lintOverlayValuesFile = "values.lint.yaml", + additionalValuesFilesGlobPattern = "values*.yaml" + } + }, } - } } --- restart LSP server avoir problems with Helm-ls -vim.api.nvim_create_autocmd("FileType", { - pattern = "helm", - command = "LspRestart", -}) - lspconfig.lua_ls.setup { capabilities = capabilities, single_file_support = true, @@ -111,67 +64,22 @@ lspconfig.tflint.setup{ capabilities = capabilities, } --- YAML configuration (quite big!) - -local cfg = require("yaml-companion").setup({ - schemas = { - { name = "Flux2", uri = flux2 }, - { name = "Gitlab", uri = gitlab }, - { name = "Taskfile", uri = taskfile }, - { name = "PodMonitor", uri = podmonitor }, - { name = "ServiceMonitor", uri = servicemonitor }, - { name = "Prometheus", uri = prometheus }, - { name = "Kubernetes", uri = kubernetes }, - { name = "Lefthook", uri = lefthook }, - }, - lspconfig = { +lspconfig.yamlls.setup{ capabilities = capabilities, - settings = { - yaml = { - schemas = { - [flux2] = { - "*.{alert,provider,receiver,helmrelease,helmrepository,gitrepository}.yaml", - "gotk-sync.yaml", - "gotk-*.yaml", - }, - [gitlab] = { - "ci/*.{yaml,yml}", - ".gitlab/**/*.{yaml,yml}", - ".gitlab-ci.{yaml,yml}", - }, - [taskfile] = { - "**/Taskfile*.{yaml,yml}", - "taskfiles/**/*.{yaml,yml}", - }, - [podmonitor] = { - "*podmonitor*.{yaml,yml}" - }, - [servicemonitor] = { - "*servicemonitor*.{yaml,yml}" - }, - [prometheus] = { - "*prometheus*.{yaml,yml}" - }, - [ingress] = { - "*ingress*.{yaml,yml}" - }, - [lefthook] = { - "**/lefthook.*" - }, - [github] = { - ".github/workflow/**/*.{yaml,yml}" - } - }, - }, - }, - }, -}) - -lspconfig.yamlls.setup{cfg} + settings = { + yaml = { + schemas = { + ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.30.0/all.json"] = {"k8s/**/*.yaml", "cluster/**/*.yaml",}, + ["https://taskfile.dev/schema.json"] = {"**/Taskfile.*", "**/taskfile.*",}, + ["https://json.schemastore.org/lefthook.json"] = {"**/lefthook.*",}, + }, + }, + }, +} vim.api.nvim_create_autocmd('LspAttach', { desc = 'LSP actions', - callback = function(ev) + callback = function() local bufmap = function(mode, lhs, rhs) local opts = {buffer = true} vim.keymap.set(mode, lhs, rhs, opts) @@ -213,9 +121,5 @@ vim.api.nvim_create_autocmd('LspAttach', { -- Move to the next diagnostic bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') - local client = vim.lsp.get_client_by_id(ev.data.client_id) - if client.name == "yamlls" then - bufmap ('n', '', 'lua require("yaml-companion").open_ui_select()') - end end })