Compare commits
5 commits
cac5b8a130
...
535e2391fe
Author | SHA1 | Date | |
---|---|---|---|
535e2391fe | |||
9f16f36b8b | |||
afb3f83b1e | |||
b70ac37321 | |||
c2dc77e360 |
4 changed files with 164 additions and 24 deletions
|
@ -10,6 +10,16 @@ let
|
||||||
url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug";
|
url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug";
|
||||||
sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58";
|
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
|
in
|
||||||
{
|
{
|
||||||
options.modules.cli.neovim = {
|
options.modules.cli.neovim = {
|
||||||
|
@ -44,6 +54,7 @@ in
|
||||||
# Formatters
|
# Formatters
|
||||||
nixfmt-rfc-style
|
nixfmt-rfc-style
|
||||||
shfmt
|
shfmt
|
||||||
|
yamlfmt
|
||||||
];
|
];
|
||||||
extraLuaConfig = (builtins.readFile ./files/options.lua);
|
extraLuaConfig = (builtins.readFile ./files/options.lua);
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = with pkgs.vimPlugins; [
|
||||||
|
@ -69,6 +80,11 @@ in
|
||||||
cmp-path
|
cmp-path
|
||||||
cmp-cmdline
|
cmp-cmdline
|
||||||
cmp_luasnip
|
cmp_luasnip
|
||||||
|
{
|
||||||
|
plugin = conform-nvim;
|
||||||
|
type = "lua";
|
||||||
|
config = (builtins.readFile ./files/conform.lua);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
plugin = fzf-lua;
|
plugin = fzf-lua;
|
||||||
type = "lua";
|
type = "lua";
|
||||||
|
@ -181,6 +197,15 @@ in
|
||||||
type = "lua";
|
type = "lua";
|
||||||
config = ( builtins.readFile ./files/whichkey.lua );
|
config = ( builtins.readFile ./files/whichkey.lua );
|
||||||
}
|
}
|
||||||
|
# yaml companion
|
||||||
|
{
|
||||||
|
plugin = ( fromGitHub
|
||||||
|
"131b0d67bd2e0f1a02e0daf2f3460482221ce3c0"
|
||||||
|
"main"
|
||||||
|
"someone-stole-my-name/yaml-companion.nvim"
|
||||||
|
);
|
||||||
|
type = "lua";
|
||||||
|
}
|
||||||
vim-helm
|
vim-helm
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
11
modules/home-manager/cli/neovim/files/conform.lua
Normal file
11
modules/home-manager/cli/neovim/files/conform.lua
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
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" },
|
||||||
|
}
|
||||||
|
})
|
|
@ -13,6 +13,14 @@ 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', '<leader>fb', function() require('fzf-lua').buffers() end, {desc='open [b]uffers'})
|
vim.keymap.set('n', '<leader>fb', function() require('fzf-lua').buffers() end, {desc='open [b]uffers'})
|
||||||
vim.keymap.set('n', '<leader>ff', function() require('fzf-lua').files() end, {desc='[r]esume last command'})
|
vim.keymap.set('n', '<leader>ff', function() require('fzf-lua').files() end, {desc='[r]esume last command'})
|
||||||
vim.keymap.set('n', '<leader>fr', function() require('fzf-lua').files() end, {desc='[f]iles'})
|
vim.keymap.set('n', '<leader>fr', function() require('fzf-lua').files() end, {desc='[f]iles'})
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require('lspconfig')
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
require("yaml-companion").open_ui_select()
|
||||||
|
|
||||||
lspconfig.bashls.setup {
|
lspconfig.bashls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
@ -13,19 +14,65 @@ lspconfig.eslint.setup{
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
|
|
||||||
lspconfig.helm_ls.setup{
|
-- YAML variables and Helm LS (quite big!)
|
||||||
capabilities = capabilities,
|
local schemas = {}
|
||||||
settings = {
|
|
||||||
['helm-ls'] = {
|
local kubernetes = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.29.6-standalone-strict/all.json"
|
||||||
logLevel = "info",
|
local flux2 = "https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/refs/heads/main/all.json"
|
||||||
valuesFiles = {
|
local gitlab = "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"
|
||||||
mainValuesFile = "values.yaml",
|
local taskfile = "https://taskfile.dev/schema.json"
|
||||||
lintOverlayValuesFile = "values.lint.yaml",
|
local podmonitor = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/refs/heads/main/monitoring.coreos.com/podmonitor_v1.json"
|
||||||
additionalValuesFilesGlobPattern = "values*.yaml"
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- restart LSP server avoir problems with Helm-ls
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "helm",
|
||||||
|
command = "LspRestart",
|
||||||
|
})
|
||||||
|
|
||||||
lspconfig.lua_ls.setup {
|
lspconfig.lua_ls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
@ -64,22 +111,67 @@ lspconfig.tflint.setup{
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
|
|
||||||
lspconfig.yamlls.setup{
|
-- 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 = {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
settings = {
|
settings = {
|
||||||
yaml = {
|
yaml = {
|
||||||
schemas = {
|
schemas = {
|
||||||
["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.30.0/all.json"] = {"k8s/**/*.yaml", "cluster/**/*.yaml",},
|
[flux2] = {
|
||||||
["https://taskfile.dev/schema.json"] = {"**/Taskfile.*", "**/taskfile.*",},
|
"*.{alert,provider,receiver,helmrelease,helmrepository,gitrepository}.yaml",
|
||||||
["https://json.schemastore.org/lefthook.json"] = {"**/lefthook.*",},
|
"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}
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
desc = 'LSP actions',
|
desc = 'LSP actions',
|
||||||
callback = function()
|
callback = function(ev)
|
||||||
local bufmap = function(mode, lhs, rhs)
|
local bufmap = function(mode, lhs, rhs)
|
||||||
local opts = {buffer = true}
|
local opts = {buffer = true}
|
||||||
vim.keymap.set(mode, lhs, rhs, opts)
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
|
@ -121,5 +213,9 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
|
||||||
-- Move to the next diagnostic
|
-- Move to the next diagnostic
|
||||||
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
||||||
|
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||||
|
if client.name == "yamlls" then
|
||||||
|
bufmap ('n', '<F3>', '<cmd>lua require("yaml-companion").open_ui_select()<cr>')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue