commit a1466c3cf4ce8e34aa1c0813b3f6780220cd3d47
parent f20fa0b4527346f6fb9c64b25a241e486700e0b5
Author: Alex Balgavy <alex@balgavy.eu>
Date: Sun, 31 Aug 2025 15:18:43 +0200
nvim: config updates
Diffstat:
2 files changed, 143 insertions(+), 104 deletions(-)
diff --git a/nvim/lua/plugins/formatting.lua b/nvim/lua/plugins/formatting.lua
@@ -1,16 +1,16 @@
-- Autoformat
return {
- 'stevearc/conform.nvim',
- event = { 'BufWritePre' },
- cmd = { 'ConformInfo' },
+ "stevearc/conform.nvim",
+ event = { "BufWritePre" },
+ cmd = { "ConformInfo" },
keys = {
{
- 'gQ',
+ "gQ",
function()
- require('conform').format { async = true, lsp_fallback = true }
+ require("conform").format({ async = true, lsp_fallback = true })
end,
- mode = '',
- desc = '[F]ormat buffer',
+ mode = "",
+ desc = "[F]ormat buffer",
},
},
opts = {
@@ -30,6 +30,10 @@ return {
inherit = true,
append_args = { "--config", "~/Documents/cdmi/automation/meta-files/ruff.toml" },
},
+ stylua = {
+ inherit = true,
+ append_args = { "--indent-width", "2", "--indent-type", "Spaces" },
+ },
},
formatters_by_ft = {
rust = { "rustfmt", lsp_format = "fallback" },
diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua
@@ -12,72 +12,72 @@ local on_attach = function(_, bufnr)
-- for LSP related items. It sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
- desc = 'LSP: ' .. desc
+ desc = "LSP: " .. desc
end
- vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
+ vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
- nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
- nmap('<leader>ra', vim.lsp.buf.code_action, '[C]ode [A]ction')
- vim.keymap.set('v', '<leader>ra', vim.lsp.buf.code_action, { buffer = bufnr, desc = '[C]ode [A]ction' })
+ nmap("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
+ nmap("<leader>ra", vim.lsp.buf.code_action, "[C]ode [A]ction")
+ vim.keymap.set("v", "<leader>ra", vim.lsp.buf.code_action, { buffer = bufnr, desc = "[C]ode [A]ction" })
- nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
- nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
- nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
+ nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
+ nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
+ nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
-- See `:help K` for why this keymap
- nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
- nmap('<leader>K', vim.lsp.buf.signature_help, 'Signature Documentation')
+ nmap("K", vim.lsp.buf.hover, "Hover Documentation")
+ nmap("<leader>K", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
- nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
- nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
- nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
- nmap('<leader>wl', function()
+ nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
+ nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
+ nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
+ nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
- end, '[W]orkspace [L]ist Folders')
+ end, "[W]orkspace [L]ist Folders")
-- Create a command `:Format` local to the LSP buffer
- vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
+ vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()
- end, { desc = 'Format current buffer with LSP' })
+ end, { desc = "Format current buffer with LSP" })
- vim.api.nvim_buf_create_user_command(bufnr, 'LspInspect', function(_)
- vim.ui.input({ prompt = 'Enter LSP Client name: ' }, function(client_name)
+ vim.api.nvim_buf_create_user_command(bufnr, "LspInspect", function(_)
+ vim.ui.input({ prompt = "Enter LSP Client name: " }, function(client_name)
if client_name then
- local client = vim.lsp.get_clients { name = client_name }
+ local client = vim.lsp.get_clients({ name = client_name })
if #client == 0 then
- vim.notify('No active LSP clients found with this name: ' .. client_name, vim.log.levels.WARN)
+ vim.notify("No active LSP clients found with this name: " .. client_name, vim.log.levels.WARN)
return
end
-- Create a temporary buffer to show the configuration
local buf = vim.api.nvim_create_buf(false, true)
local win = vim.api.nvim_open_win(buf, true, {
- relative = 'editor',
+ relative = "editor",
width = math.floor(vim.o.columns * 0.75),
height = math.floor(vim.o.lines * 0.90),
col = math.floor(vim.o.columns * 0.125),
row = math.floor(vim.o.lines * 0.05),
- style = 'minimal',
- border = 'rounded',
- title = ' ' .. (client_name:gsub('^%l', string.upper)) .. ': LSP Configuration ',
- title_pos = 'center',
+ style = "minimal",
+ border = "rounded",
+ title = " " .. (client_name:gsub("^%l", string.upper)) .. ": LSP Configuration ",
+ title_pos = "center",
})
local lines = {}
for i, this_client in ipairs(client) do
if i > 1 then
- table.insert(lines, string.rep('-', 80))
+ table.insert(lines, string.rep("-", 80))
end
- table.insert(lines, 'Client: ' .. this_client.name)
- table.insert(lines, 'ID: ' .. this_client.id)
- table.insert(lines, '')
- table.insert(lines, 'Configuration:')
+ table.insert(lines, "Client: " .. this_client.name)
+ table.insert(lines, "ID: " .. this_client.id)
+ table.insert(lines, "")
+ table.insert(lines, "Configuration:")
- local config_lines = vim.split(vim.inspect(this_client.config), '\n')
+ local config_lines = vim.split(vim.inspect(this_client.config), "\n")
vim.list_extend(lines, config_lines)
end
@@ -86,21 +86,21 @@ local on_attach = function(_, bufnr)
-- Set buffer options
vim.bo[buf].modifiable = false
- vim.bo[buf].filetype = 'lua'
- vim.bo[buf].bh = 'delete'
+ vim.bo[buf].filetype = "lua"
+ vim.bo[buf].bh = "delete"
- vim.api.nvim_buf_set_keymap(buf, 'n', 'q', ':q<CR>', { noremap = true, silent = true })
+ vim.api.nvim_buf_set_keymap(buf, "n", "q", ":q<CR>", { noremap = true, silent = true })
end
end)
- end, { desc = 'Inspect LSP config' })
+ end, { desc = "Inspect LSP config" })
end
-- :h lspconfig-all
local config = function()
- vim.lsp.config('rust_analyzer', {
+ vim.lsp.config("rust_analyzer", {
on_attach = on_attach,
settings = {
- ['rust-analyzer'] = {
+ ["rust-analyzer"] = {
workspace = {
symbol = {
search = {
@@ -113,41 +113,68 @@ local config = function()
features = "all",
extraArgs = {
"--",
- "-D", "clippy::pedantic",
- "-D", "clippy::nursery",
- "-D", "clippy::restriction",
- "-A", "clippy::blanket_clippy_restriction_lints",
- "-A", "clippy::missing_docs_in_private_items",
- "-A", "clippy::implicit_return",
- "-A", "clippy::question_mark_used",
- "-A", "clippy::min_ident_chars",
- "-A", "clippy::pattern_type_mismatch",
- "-A", "clippy::single_call_fn",
- "-A", "clippy::as_conversions",
- "-A", "clippy::pub_with_shorthand",
- "-A", "clippy::shadow_reuse",
- "-A", "clippy::separated_literal_suffix",
- "-A", "clippy::float_arithmetic",
- "-A", "clippy::pub_use",
- "-A", "clippy::single_char_lifetime_names",
- "-A", "clippy::missing_trait_methods",
- "-A", "clippy::mod_module_files",
- "-A", "clippy::std_instead_of_alloc",
- "-A", "clippy::integer_division_remainder_used",
- "-D", "rust_2018_idioms",
- "-D", "missing_docs",
- "-D", "warnings",
- "-A", "clippy::too_many_lines",
- "-A", "clippy::arbitrary_source_item_ordering",
- "-A", "clippy::redundant_test_prefix",
+ "-D",
+ "clippy::pedantic",
+ "-D",
+ "clippy::nursery",
+ "-D",
+ "clippy::restriction",
+ "-A",
+ "clippy::blanket_clippy_restriction_lints",
+ "-A",
+ "clippy::missing_docs_in_private_items",
+ "-A",
+ "clippy::implicit_return",
+ "-A",
+ "clippy::question_mark_used",
+ "-A",
+ "clippy::min_ident_chars",
+ "-A",
+ "clippy::pattern_type_mismatch",
+ "-A",
+ "clippy::single_call_fn",
+ "-A",
+ "clippy::as_conversions",
+ "-A",
+ "clippy::pub_with_shorthand",
+ "-A",
+ "clippy::shadow_reuse",
+ "-A",
+ "clippy::separated_literal_suffix",
+ "-A",
+ "clippy::float_arithmetic",
+ "-A",
+ "clippy::pub_use",
+ "-A",
+ "clippy::single_char_lifetime_names",
+ "-A",
+ "clippy::missing_trait_methods",
+ "-A",
+ "clippy::mod_module_files",
+ "-A",
+ "clippy::std_instead_of_alloc",
+ "-A",
+ "clippy::integer_division_remainder_used",
+ "-D",
+ "rust_2018_idioms",
+ "-D",
+ "missing_docs",
+ "-D",
+ "warnings",
+ "-A",
+ "clippy::too_many_lines",
+ "-A",
+ "clippy::arbitrary_source_item_ordering",
+ "-A",
+ "clippy::redundant_test_prefix",
},
- }
- }
+ },
+ },
},
})
- vim.lsp.enable('rust_analyzer')
+ vim.lsp.enable("rust_analyzer")
- vim.lsp.config('bacon_ls', {
+ vim.lsp.config("bacon_ls", {
on_attach = on_attach,
init_options = {
updateOnSave = true,
@@ -162,26 +189,28 @@ local config = function()
--]]
-- vim.lsp.enable('bacon_ls')
- vim.lsp.config('yamlls', { on_attach = on_attach })
- vim.lsp.enable('yamlls')
+ vim.lsp.config("yamlls", { on_attach = on_attach })
+ vim.lsp.enable("yamlls")
- vim.lsp.config('nixd', { on_attach = on_attach })
- vim.lsp.enable('nixd')
+ vim.lsp.config("nixd", { on_attach = on_attach })
+ vim.lsp.enable("nixd")
- vim.lsp.config('lua_ls', {
+ vim.lsp.config("lua_ls", {
on_attach = on_attach,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
- version = 'LuaJIT',
+ version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {
- 'vim',
- 'require'
+ "vim",
+ "require",
+ "hs",
+ "spoon",
},
},
workspace = {
@@ -192,45 +221,51 @@ local config = function()
telemetry = {
enable = false,
},
- }
- }
+ },
+ },
})
- vim.lsp.enable('lua_ls')
+ vim.lsp.enable("lua_ls")
- vim.lsp.enable('basedpyright')
+ vim.lsp.enable("basedpyright")
- vim.lsp.config('vue_ls', {
+ vim.lsp.config("vue_ls", {
-- add filetypes for typescript, javascript and vue
- filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
+ filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
})
- vim.lsp.enable('vue_ls')
+ vim.lsp.enable("vue_ls")
- vim.lsp.enable('terraformls')
+ vim.lsp.enable("terraformls")
- vim.lsp.config('ruby_lsp', {
+ vim.lsp.config("ruby_lsp", {
init_options = {
- formatter = 'standard',
- linters = { 'standard' },
+ formatter = "standard",
+ linters = { "standard" },
},
})
- vim.lsp.enable('ruby_lsp')
+ vim.lsp.enable("ruby_lsp")
+ vim.lsp.config("nil_ls", {
+ init_options = {
+ root_markers = { "flake.nix", ".git", "darwin-configuration.nix" },
+ },
+ })
+ vim.lsp.enable("nil_ls")
end
return {
{
- 'neovim/nvim-lspconfig',
+ "neovim/nvim-lspconfig",
config = config,
},
{
- 'mfussenegger/nvim-lint',
+ "mfussenegger/nvim-lint",
config = function()
- local lint = require('lint')
+ local lint = require("lint")
lint.linters_by_ft = {
- sh = { 'shellcheck' },
+ sh = { "shellcheck" },
}
- local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
- vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
+ local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
+ vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
-- Only run the linter in buffers that you can modify in order to
@@ -240,6 +275,6 @@ return {
end
end,
})
- end
- }
+ end,
+ },
}