Compare commits

...

10 Commits

21 changed files with 507 additions and 602 deletions

View File

@ -34,3 +34,24 @@ require("lazy").setup({
backdrop = 100, backdrop = 100,
}, },
}) })
local lsp = require("tools.lsp")
for _, tool in pairs(lsp) do
if type(tool) == "table" then
local name = tool[1]
-- Apply additional config if specified
local config = tool[2]
if config ~= nil then
vim.lsp.config(name, config)
end
-- System LSP are not managed by mason and need to be enabled manually
if
(type(tool.system) == "boolean" and tool.system and vim.fn.executable(name) > 0)
or (type(tool.system) == "string" and vim.fn.executable(tool.system) > 0)
then
vim.lsp.enable(name)
end
end
end

View File

@ -1,14 +1,11 @@
{ {
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "faf3c94a44508cec1b961406d36cc65113ff3b98" }, "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" }, "bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" },
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
"cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" },
"document-color.nvim": { "branch": "main", "commit": "74c487f0e5accfaae033755451b9e367220693fd" },
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "8b729e489f1475615dc6c9737da917b3bc163605" }, "gitsigns.nvim": { "branch": "main", "commit": "8b729e489f1475615dc6c9737da917b3bc163605" },
"gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" }, "gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" },
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
@ -17,10 +14,9 @@
"kubernetes.nvim": { "branch": "main", "commit": "1a08abc6c0694f0d1f5d6725bfa7a88daf0f7246" }, "kubernetes.nvim": { "branch": "main", "commit": "1a08abc6c0694f0d1f5d6725bfa7a88daf0f7246" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
"lsp_signature.nvim": { "branch": "master", "commit": "2b30d8582126a12a493b737e9761969eb869a05b" },
"lspkind-nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" }, "lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" },
"luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" },
"mason-conform.nvim": { "branch": "main", "commit": "f3b96fa2217fcb1513301eefbe10ea0e765e33eb" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "d24b3f1612e53f9d54d866b16bedab51813f2bf1" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "d24b3f1612e53f9d54d866b16bedab51813f2bf1" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "75d60a8f928decd8b38897f80849768b7c540a5b" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "75d60a8f928decd8b38897f80849768b7c540a5b" },
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
@ -28,8 +24,6 @@
"nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" },
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
"nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" }, "nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-cmp-lsp-rs": { "branch": "main", "commit": "57f29333e6d2b655d5b0edb999b0006d49fde0ca" },
"nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" },
"nvim-dap": { "branch": "master", "commit": "b0f983507e3702f073bfe1516846e58b56d4e42f" }, "nvim-dap": { "branch": "master", "commit": "b0f983507e3702f073bfe1516846e58b56d4e42f" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },

View File

@ -1,15 +1,13 @@
local window = require("symbols.window")
-- Highlight on yank -- Highlight on yank
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
callback = function() callback = function()
vim.highlight.on_yank({ higroup = "YankHighlight" }) vim.highlight.on_yank({ higroup = "YankHighlight" })
end, end,
group = highlight_group,
pattern = "*",
}) })
-- show cursor line only in active window -- show cursor line only in active window
local cursor_group = vim.api.nvim_create_augroup("ActiveCursor", { clear = true })
vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, {
callback = function() callback = function()
local ok, cl = pcall(vim.api.nvim_win_get_var, 0, "auto-cursorline") local ok, cl = pcall(vim.api.nvim_win_get_var, 0, "auto-cursorline")
@ -18,8 +16,6 @@ vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, {
vim.api.nvim_win_del_var(0, "auto-cursorline") vim.api.nvim_win_del_var(0, "auto-cursorline")
end end
end, end,
group = cursor_group,
pattern = "*",
}) })
vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, { vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, {
callback = function() callback = function()
@ -29,18 +25,137 @@ vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, {
vim.wo.cursorline = false vim.wo.cursorline = false
end end
end, end,
group = cursor_group,
pattern = "*",
}) })
vim.api.nvim_create_autocmd("FileType", { -- Setup lsp keybindings
pattern = require("tools.highlight"), vim.api.nvim_create_autocmd("LspAttach", {
callback = function() callback = function(event)
-- syntax highlighting, provided by Neovim -- Symbols
vim.treesitter.start() vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Goto definition" })
-- folds, provided by Neovim vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Goto declaration" })
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, { desc = "Type definition" })
-- indentation, provided by nvim-treesitter
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" if pcall(require, "telescope") then
vim.keymap.set("n", "gr", require("telescope.builtin").lsp_references, { desc = "Goto references" })
vim.keymap.set(
"n",
"gI",
require("telescope.builtin").lsp_implementations,
{ desc = "Goto implementation" }
)
vim.keymap.set(
"n",
"<leader>ds",
require("telescope.builtin").lsp_document_symbols,
{ desc = "Document symbols" }
)
vim.keymap.set(
"n",
"<leader>ws",
require("telescope.builtin").lsp_dynamic_workspace_symbols,
{ desc = "Workspace symbols" }
)
end
-- Diagnostics
vim.keymap.set("n", "[d", function()
vim.diagnostic.jump({ count = -1 })
end, { desc = "Go to previous diagnostic message" })
vim.keymap.set("n", "]d", function()
vim.diagnostic.jump({ count = 1 })
end, { desc = "Go to next diagnostic message" })
-- vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
vim.keymap.set("n", "<leader>e", function()
if vim.diagnostic.config().virtual_lines then
vim.diagnostic.config({ virtual_lines = false })
else
vim.diagnostic.config({
virtual_lines = {
current_line = true,
format = vim.diagnostic.config().virtual_text.format,
},
})
end
end, { desc = "Show virtual diagnostic line" })
-- Helpers
vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { buffer = event.buf, expr = true, desc = "Rename" })
vim.keymap.set(
"n",
"<leader>ca",
vim.lsp.buf.code_action,
{ buffer = event.buf, desc = "Code actions", remap = true }
)
-- Documentation
-- vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, { desc = "Signature Documentation" })
end,
})
-- Setup cursor hover symbol highlight
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(event)
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
local lsp_hover_hl = vim.api.nvim_create_augroup("LspHoverHighlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
group = lsp_hover_hl,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
group = lsp_hover_hl,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd("LspDetach", {
group = vim.api.nvim_create_augroup("LspHoverHighlightDetach", { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = lsp_hover_hl, buffer = event2.buf })
end,
})
end
end,
})
-- Disable lsp based syntax highlighting
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(event)
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.semanticTokensProvider then
client.server_capabilities.semanticTokensProvider = nil
end
end,
})
--
vim.api.nvim_create_autocmd("CursorMoved", {
callback = function()
vim.diagnostic.config({ virtual_lines = false })
end,
})
-- Auto install treesitter parser and start them
vim.api.nvim_create_autocmd("FileType", {
desc = "Enable Treesitter",
group = vim.api.nvim_create_augroup("enable_treesitter", {}),
callback = function(event)
local has_treesitter, treesitter = pcall(require, "nvim-treesitter")
if has_treesitter then
local language = vim.treesitter.language.get_lang(event.match)
treesitter.install(language):await(function()
if pcall(vim.treesitter.start) then
-- Use Treesitter indentation and folds.
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end
end)
end
end, end,
}) })

View File

@ -13,11 +13,6 @@ vim.keymap.set("n", "<S-Down>", "<cmd>resize -2<CR>")
vim.keymap.set("n", "<S-Left>", "<cmd>vertical resize -2<CR>") vim.keymap.set("n", "<S-Left>", "<cmd>vertical resize -2<CR>")
vim.keymap.set("n", "<S-Right>", "<cmd>vertical resize +2<CR>") vim.keymap.set("n", "<S-Right>", "<cmd>vertical resize +2<CR>")
-- Diagnostic keymaps
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" })
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
-- Some nice adjustments -- Some nice adjustments
vim.keymap.set("n", "<C-d>", "<C-d>zz") vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz") vim.keymap.set("n", "<C-u>", "<C-u>zz")

View File

@ -1,3 +1,6 @@
local diagnostic = require("symbols.diagnostic")
local window = require("symbols.window")
-- Set highlight on search -- Set highlight on search
vim.o.hlsearch = true vim.o.hlsearch = true
@ -39,7 +42,7 @@ vim.o.termguicolors = true
-- Default tab settings -- Default tab settings
-- Tab settings are automatically detected by vim-sleuth -- Tab settings are automatically detected by vim-sleuth
-- Can be overriden by .editorconfig and modeline -- Can be overridden by .editorconfig and modeline
vim.o.tabstop = 4 vim.o.tabstop = 4
vim.o.softtabstop = 4 vim.o.softtabstop = 4
vim.o.shiftwidth = 4 vim.o.shiftwidth = 4
@ -61,3 +64,28 @@ vim.o.scrolloff = 10
-- Highlight tabs and trailing whitespace -- Highlight tabs and trailing whitespace
vim.o.listchars = "trail:~,tab:¦⁃,nbsp:␣" vim.o.listchars = "trail:~,tab:¦⁃,nbsp:␣"
vim.o.list = true vim.o.list = true
-- Fold settings
vim.o.foldlevelstart = 99
-- Windows borders
-- vim.o.winborder = window.border
-- LSP config
vim.diagnostic.config({
severity_sort = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = diagnostic.error,
[vim.diagnostic.severity.WARN] = diagnostic.warn,
[vim.diagnostic.severity.HINT] = diagnostic.hint,
[vim.diagnostic.severity.INFO] = diagnostic.info,
},
},
virtual_text = {
virt_text_pos = "eol_right_align",
format = function(d)
return ("%s [%s]"):format(d.message, d.source)
end,
},
})

View File

@ -0,0 +1,115 @@
return {
"saghen/blink.cmp",
-- optional: provides snippets for the snippet source
dependencies = { "rafamadriz/friendly-snippets" },
-- use a release tag to download pre-built binaries
version = "1.*",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
-- See :h blink-cmp-config-keymap for defining your own keymap
-- keymap = { preset = "default" },
keymap = {
preset = "default",
-- ["<C-u>"] = {function(cmp) cmp.scroll_documentation_up(4) end},
-- ["<C-d>"] = {function(cmp) cmp.scroll_documentation_down(4) end},
["<C-space>"] = { "show", "show_documentation", "hide_documentation" },
["<C-u>"] = { "scroll_documentation_up" },
["<C-d>"] = { "scroll_documentation_down" },
["<CR>"] = { "accept", "fallback" },
["<Esc>"] = { "cancel", "fallback" },
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
["<Up>"] = { "select_prev", "fallback" },
["<Down>"] = { "select_next", "fallback" },
["<C-p>"] = { "select_prev", "fallback_to_mappings" },
["<C-n>"] = { "select_next", "fallback_to_mappings" },
-- TODO: Does not appear to work?
["<C-k>"] = { "show_signature", "hide_signature", "fallback" },
},
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
},
-- (Default) Only show the documentation popup when manually triggered
completion = {
ghost_text = {
enabled = true,
},
list = {
selection = {
preselect = false,
-- preselect = function(ctx)
-- return vim.bo.filetype ~= "markdown"
-- end,
},
},
documentation = {
auto_show = true,
auto_show_delay_ms = 0,
},
menu = {
auto_show = true,
draw = {
columns = {
{ "label", "label_description", gap = 1 },
{ "kind", "source_name", gap = 1 },
},
components = {
source_name = {
text = function(ctx)
if ctx.source_id ~= "snippets" then
return "[" .. ctx.source_name .. "]"
end
end,
},
},
},
},
},
signature = {
enabled = true,
trigger = {
show_on_accept = true,
show_on_insert = true,
},
},
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = {
"lazydev",
"lsp",
"path",
"snippets",
"buffer",
},
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
},
},
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" },
},
opts_extend = { "sources.default" },
}

View File

@ -1,114 +0,0 @@
-- https://github.com/hrsh7th/nvim-cmp
return {
{
-- Autocompletion
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"onsails/lspkind-nvim",
-- Improve sorting order for rust
"zjp-CN/nvim-cmp-lsp-rs",
-- Snippets
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
local border = require("symbols.window").border
local cmp_rs = require("cmp_lsp_rs")
local comparators = cmp_rs.comparators
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = "menu,menuone,noinsert" },
window = {
completion = cmp.config.window.bordered({
border = border,
winhighlight = "CursorLine:CmpSelection",
}),
documentation = cmp.config.window.bordered({ border = border }),
},
-- Include the source of the cmp entry
formatting = {
format = lspkind.cmp_format({
mode = "text",
menu = {
nvim_lsp = "LSP",
luasnip = "LuaSnip",
path = "Path",
},
}),
},
mapping = cmp.mapping.preset.insert({
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}),
["<CR>"] = cmp.mapping.confirm({
select = true,
}),
["<Esc>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.abort()
else
fallback()
end
end, { "i", "s" }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sorting = {
comparators = {
comparators.inherent_import_inscope,
comparators.sort_by_label_but_underscore_last,
},
},
sources = {
{ name = "lazydev", group_index = 0 },
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
},
})
end,
},
{
"L3MON4D3/LuaSnip",
build = "make install_jsregexp",
cond = function()
return vim.fn.executable("make") == 1
end,
config = function()
require("luasnip").config.setup()
-- require("luasnip.loaders.from_vscode").lazy_load()
end,
dependencies = {
-- "rafamadriz/friendly-snippets",
},
},
}

View File

@ -1,11 +1,7 @@
-- https://github.com/stevearc/conform.nvim -- https://github.com/stevearc/conform.nvim
local slow_format_filetypes = {} local slow_format_filetypes = {}
return { return {
"stevearc/conform.nvim", "stevearc/conform.nvim",
dependencies = {
"williamboman/mason.nvim",
},
event = { "BufWritePre" }, event = { "BufWritePre" },
cmd = { "ConformInfo" }, cmd = { "ConformInfo" },
keys = { keys = {
@ -20,7 +16,24 @@ return {
}, },
}, },
opts = { opts = {
formatters_by_ft = require("tools").formatters, formatters_by_ft = (function()
local formatters = require("tools.format")
local formatters_by_ft = {}
for lang, formatter in pairs(formatters) do
formatters_by_ft[lang] = {}
if type(formatter) == "table" then
for _, tool in ipairs(formatter) do
if type(tool) == "table" then
table.insert(formatters_by_ft[lang], tool[1])
else
table.insert(formatters_by_ft[lang], tool)
end
end
end
end
return formatters_by_ft
end)(),
notify_on_error = false, notify_on_error = false,
format_on_save = function(bufnr) format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then

View File

@ -1,140 +0,0 @@
return {
-- LSP Configuration & Plugins
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
-- Some of the lsp keybindings rely on telescope
"nvim-telescope/telescope.nvim",
-- Set capabilities from cmp
"hrsh7th/cmp-nvim-lsp",
-- Add document color
"mrshmllow/document-color.nvim",
"b0o/schemastore.nvim",
-- Rename with immediate visual feedback
},
config = function()
local border = require("symbols.window").border
-- Set borders
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }),
}
require("lspconfig.ui.windows").default_options = {
border = border,
}
vim.diagnostic.config({
severity_sort = true,
})
-- Create the signs for diagnostic symbols
local diagnostic = require("symbols.diagnostic")
local signs = {
Error = diagnostic.error,
Warn = diagnostic.warn,
Hint = diagnostic.hint,
Info = diagnostic.info,
}
for type, icon in pairs(signs) do
local hl_sign = "DiagnosticSign" .. type
local hl_text = "Diagnostic" .. type
vim.fn.sign_define(hl_sign, { text = icon, texthl = hl_sign })
end
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
callback = function(event)
local map = function(keys, func, desc)
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP:" .. desc })
end
map("gd", vim.lsp.buf.definition, "Goto definition")
map("gr", require("telescope.builtin").lsp_references, "Goto references")
map("gI", require("telescope.builtin").lsp_implementations, "Goto implementation")
map("<leader>D", vim.lsp.buf.type_definition, "Type definition")
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "Document symbols")
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Workspace symbols")
vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { buffer = event.buf, expr = true, desc = "Rename" })
-- TODO: Do we need this to work in visal mode?
vim.keymap.set(
{ "v", "n" },
"<leader>ca",
vim.lsp.buf.code_action,
{ buffer = event.buf, desc = "Code actions", remap = true }
)
-- Signature help
map("K", vim.lsp.buf.hover, "Hover Documentation")
map("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
map("gD", vim.lsp.buf.declaration, "Goto declaration")
local client = vim.lsp.get_client_by_id(event.data.client_id)
-- Turn of lsp based syntax highlighting
if client then
client.server_capabilities.semanticTokensProvider = nil
if client.server_capabilities.documentHighlightProvider then
local highlight_augrup = vim.api.nvim_create_augroup("lsp-highlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
group = highlight_augrup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
group = highlight_augrup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd("LspDetach", {
group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = highlight_augrup, buffer = event2.buf })
end,
})
end
end
end,
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- TODO: Only do this is cmp_nvim_lsp is enabled
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
capabilities.textDocument.colorProvider = {
dynamicRegistration = true,
}
local handler = function(server_name)
local server = require("tools").servers()[server_name] or {}
server.capabilities = vim.tbl_deep_extend("force", capabilities, server.capabilities or {})
server.handlers = handlers
require("lspconfig")[server_name].setup(server)
end
for server, config in pairs(require("tools").servers()) do
if config.system then
handler(server)
end
end
require("mason-lspconfig").setup({
handlers = { handler },
})
end,
}

View File

@ -1,14 +0,0 @@
-- https://github.com/ray-x/lsp_signature.nvim
return {
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
dependencies = {
"neovim/nvim-lspconfig",
},
opts = {
hint_enable = false,
handler_opts = {
border = require("symbols.window").border,
},
},
}

View File

@ -1,35 +1,96 @@
return { return {
{
"williamboman/mason.nvim",
opts = {
ui = {
border = require("symbols.window").border,
height = 0.8,
},
},
},
{ {
"WhoIsSethDaniel/mason-tool-installer.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim",
dependencies = { dependencies = {
"williamboman/mason.nvim", { "mason-org/mason.nvim", opts = {} },
"mason-org/mason-lspconfig.nvim",
"zapling/mason-conform.nvim",
}, },
config = function() config = function()
local tools = require("tools") local lsp = require("tools.lsp")
local ensure_installed = vim.tbl_keys(vim.tbl_map(function(tool)
if tool.system then -- Convert lsp entries to consistent format
return nil local tools = {}
for _, tool in pairs(lsp) do
if type(tool) == "table" then
local name = tool[1]
local entry = {}
-- Make a copy and strip out name and lsp config
for k, v in pairs(tool) do
if k ~= 1 and k ~= 2 then
entry[k] = v
end
end
tools[name] = entry
else else
return tool tools[tool] = {}
end end
end, tools.servers())) end
ensure_installed =
vim.list_extend(ensure_installed, require("util.mason").process_formatters(tools.formatters)) -- Convert formatters to same format and merge on top of the lsps
ensure_installed = vim.list_extend(ensure_installed, tools.extra) local formatters_by_ft = require("conform").formatters_by_ft
local mapping = require("mason-conform.mapping")
for _, formatter in pairs(formatters_by_ft) do
if type(formatter) == "table" then
for _, tool in ipairs(formatter) do
local entry = {}
local name = nil
if type(tool) == "table" then
name = mapping.conform_to_package[tool[1]]
-- Make a copy and strip out name
for k, v in pairs(tool) do
if k ~= 1 then
entry[k] = v
end
end
else
name = mapping.conform_to_package[tool]
end
if name ~= nil then
tools[name] = vim.tbl_extend("error", tools[name] or {}, entry)
end
end
end
end
local ensure_installed = vim.iter(tools)
:map(function(name, tool)
if type(tool) == "table" then
if tool.system then
return nil
end
local entry = {
[1] = name,
}
for k, v in pairs(tool) do
entry[k] = v
end
return entry
end
return tool
end)
:totable()
require("mason-tool-installer").setup({ require("mason-tool-installer").setup({
ensure_installed = ensure_installed, ensure_installed = ensure_installed,
auto_update = true, auto_update = true,
debounde_hours = 24,
}) })
end, end,
}, },
{
"mason-org/mason-lspconfig.nvim",
opts = {},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",
},
},
} }

View File

@ -0,0 +1,13 @@
return {
"b0o/schemastore.nvim",
config = function()
vim.lsp.config("jsonls", {
settings = {
json = {
validate = { enable = true },
schemas = require("schemastore").json.schemas(),
},
},
})
end
}

View File

@ -1,4 +1,5 @@
-- https://github.com/nvim-telescope/telescope.nvim -- https://github.com/nvim-telescope/telescope.nvim
local window = require("symbols.window")
-- TODO: Ensure installed ripgrep -- TODO: Ensure installed ripgrep
return { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
@ -35,7 +36,7 @@ return {
["<S-Tab>"] = "move_selection_better", ["<S-Tab>"] = "move_selection_better",
}, },
}, },
borderchars = require("symbols.window").borderchars, borderchars = window.borderchars,
}, },
extensions = { extensions = {
["ui-select"] = { ["ui-select"] = {
@ -44,6 +45,20 @@ return {
}, },
}) })
-- HACK: Workaround until new borders are fixed in telescope
vim.api.nvim_create_autocmd("User", {
pattern = "TelescopeFindPre",
callback = function()
vim.opt_local.winborder = "none"
vim.api.nvim_create_autocmd("WinLeave", {
once = true,
callback = function()
vim.opt_local.winborder = window.border
end,
})
end,
})
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")
require("telescope").load_extension("ui-select") require("telescope").load_extension("ui-select")

View File

@ -11,12 +11,8 @@ return {
branch = "main", branch = "main",
build = ":TSUpdate", build = ":TSUpdate",
opts = { opts = {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = require("tools.highlight"), ensure_installed = require("tools.highlight"),
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
incremental_selection = { incremental_selection = {
@ -80,12 +76,4 @@ return {
}, },
}, },
}, },
{
"nvim-treesitter/nvim-treesitter-context",
opts = {
multiwindow = true,
mode = "topline",
separator = require("symbols.window").borderchars[3],
},
},
} }

View File

@ -1,11 +1,19 @@
return { return {
"someone-stole-my-name/yaml-companion.nvim", "someone-stole-my-name/yaml-companion.nvim",
dependencies = { dependencies = {
"neovim/nvim-lspconfig",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"nvim-telescope/telescope.nvim",
"diogo464/kubernetes.nvim",
}, },
config = function() config = function()
require("telescope").load_extension("yaml_schema") require("telescope").load_extension("yaml_schema")
vim.lsp.config("yamlls", require("yaml-companion").setup({
builtin_matchers = {
kubernetes = { enabled = false },
kubernetes_custom = { enabled = true },
},
}))
end, end,
} }

View File

@ -27,11 +27,13 @@ return {
TelescopeMatching = { fg = palette.bright_aqua, bold = true }, TelescopeMatching = { fg = palette.bright_aqua, bold = true },
TelescopeSelection = { fg = palette.bright_blue }, TelescopeSelection = { fg = palette.bright_blue },
TelescopeSelectionCaret = { link = "TelescopeSelection" }, TelescopeSelectionCaret = { link = "TelescopeSelection" },
CmpItemAbbrMatch = { fg = palette.bright_aqua, bold = true }, BlinkCmpMenu = { fg = palette.dark2 },
CmpItemAbbrMatchFuzzy = { link = "CmpItemAbbrMatch" }, BlinkCmpMenuBorder = { fg = palette.dark4 },
CmpItemMenu = { fg = palette.dark2 }, BlinkCmpDocBorder = { fg = palette.dark4 },
CmpItemKindFunction = { fg = palette.bright_red }, BlinkCmpDocSeparator = { fg = palette.dark4 },
CmpSelection = { fg = palette.dark0, bg = palette.bright_blue }, BlinkCmpSignatureHelpBorder = { fg = palette.dark4 },
BlinkCmpKindFunction = { fg = palette.bright_red },
BlinkCmpMenuSelection = { fg = palette.dark0, bg = palette.bright_blue },
LspReferenceText = { bg = palette.dark1 }, LspReferenceText = { bg = palette.dark1 },
LspReferenceRead = { link = "LspReferenceText" }, LspReferenceRead = { link = "LspReferenceText" },
LspReferenceWrite = { link = "LspReferenceText" }, LspReferenceWrite = { link = "LspReferenceText" },

View File

@ -1,79 +0,0 @@
local tools = {}
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
tools.servers = function()
return {
clangd = {
cmd = { "clangd", "--offset-encoding=utf-16", "--clang-tidy" },
},
gopls = {},
pyright = {},
rust_analyzer = {
system = true,
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
},
},
},
},
lua_ls = {
settings = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
},
jsonls = {
settings = {
json = {
validate = { enable = true },
schemas = require("schemastore").json.schemas(),
},
},
},
yamlls = require("yaml-companion").setup({
builtin_matchers = {
kubernetes = { enabled = false },
kubernetes_custom = { enabled = true },
},
}),
taplo = {},
neocmake = {},
nil_ls = {
system = true,
},
typos_lsp = {
init_options = {
diagnosticSeverity = "Hint",
},
},
}
end
-- https://github.com/stevearc/conform.nvim
tools.formatters = require("util.conform").assign_formatters({
{ { "c", "cpp" }, { "clang-format" } },
go = { "goimports", "gofmt" },
python = { "ruff_format" },
rust = { "rustfmt" },
{
{ "javascript", "typescript", "typescriptreact", "javascriptreact", "css", "markdown", "yaml" },
{ "prettierd" },
},
lua = { "stylua" },
json = { "jq" },
toml = { "taplo" },
nix = { "nixfmt" },
-- ["*"] = { "injected" },
["_"] = { "trim_whitespace", "trim_newlines" },
})
-- https://mason-registry.dev/registry/list
tools.extra = {
"cpptools",
}
return tools

View File

@ -0,0 +1,19 @@
return {
c = { "clang-format" },
cpp = { "clang-format" },
go = { "goimports", "gofmt" },
python = { "ruff_organize_imports", "ruff_format" },
rust = { { "rustfmt", system = true } },
javascript = { "prettierd" },
javascriptreact = { "prettierd" },
typescript = { "prettierd" },
typescriptreact = { "prettierd" },
css = { "prettierd" },
markdown = { "prettierd" },
yaml = { "prettierd" },
lua = { "stylua" },
json = { "jq" },
toml = { "taplo" },
-- ["*"] = { "injected" },
["_"] = { "trim_whitespace", "trim_newlines" },
}

View File

@ -0,0 +1,45 @@
return {
{
"rust_analyzer",
{
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
},
},
},
},
system = "rust-analyzer",
},
{ "typos_lsp", {
init_options = {
diagnosticSeverity = "Hint",
},
} },
{ "clangd", {
cmd = { "clangd", "--offset-encoding=utf-16", "--clang-tidy" },
} },
"basedpyright",
{
"lua_ls",
{
settings = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
},
},
{
"gopls",
condition = function()
return vim.fn.executable("go") > 0
end,
},
"jsonls",
"yamlls",
"taplo",
"neocmake",
}

View File

@ -1,18 +0,0 @@
-- Helper function for assigning formatters to multiple languages at the same time
local M = {}
function M.assign_formatters(input)
local table = {}
for k, v in pairs(input) do
if type(k) == "number" then
for _, lang in pairs(v[1]) do
table[lang] = v[2]
end
else
table[k] = v
end
end
return table
end
return M

View File

@ -1,162 +0,0 @@
-- Based on: https://github.com/zapling/mason-conform.nvim
-- conform formatter to mason package mapping
-- https://mason-registry.dev/registry/list
local conform_to_mason = {
-- alejandra
["asmfmt"] = "asmfmt",
["ast-grep"] = "ast-grep",
-- astyle
-- auto_optional
-- autocorrect
["autoflake"] = "autoflake",
["autopep8"] = "autopep8",
-- awk
-- bean-format
["beautysh"] = "beautysh",
["bibtex-tidy"] = "bibtex-tidy",
-- biome-check
["biome"] = "biome",
["black"] = "black",
["blade-formatter"] = "blade-formatter",
["blue"] = "blue",
["buf"] = "buf",
["buildifier"] = "buildifier",
["cbfmt"] = "cbfmt",
["clang-format"] = "clang-format",
-- cljstyle
["cmake_format"] = "cmakelang",
["codespell"] = "codespell",
["csharpier"] = "csharpier",
-- cue_fmt
["darker"] = "darker",
-- dart_format
["deno_fmt"] = "deno",
-- dfmt
["djlint"] = "djlint",
["dprint"] = "dprint",
["easy-coding-standard"] = "easy-coding-standard",
["elm_format"] = "elm-format",
-- erb_format
["eslint_d"] = "eslint_d",
["fantomas"] = "fantomas",
-- fish_indent
["fixjson"] = "fixjson",
-- fnlfmt
["fourmolu"] = "fourmolu",
["gci"] = "gci",
["gdformat"] = "gdtoolkit",
["gersemi"] = "gersemi",
-- gn
-- gofmt
["gofumpt"] = "gofumpt",
["goimports-reviser"] = "goimports-reviser",
["goimports"] = "goimports",
["golines"] = "golines",
["google-java-format"] = "google-java-format",
["htmlbeautifier"] = "htmlbeautifier",
-- indent
-- init
-- injected
["isort"] = "isort",
["joker"] = "joker",
["jq"] = "jq",
["jsonnetfmt"] = "jsonnetfmt",
-- just
["ktlint"] = "ktlint",
["latexindent"] = "latexindent",
["markdown-toc"] = "markdown-toc",
["markdownlint-cli2"] = "markdownlint-cli2",
["markdownlint"] = "markdownlint",
["mdformat"] = "mdformat",
["mdslw"] = "mdslw",
-- mix
-- nixfmt
["nixpkgs_fmt"] = "nixpkgs-fmt",
["ocamlformat"] = "ocamlformat",
-- opa_fmt
-- packer_fmt
-- pangu
-- perlimports
-- perltidy
-- pg_format
["php_cs_fixer"] = "php-cs-fixer",
["phpcbf"] = "phpcbf",
-- phpinsights
["pint"] = "pint",
["prettier"] = "prettier",
["prettierd"] = "prettierd",
["pretty-php"] = "pretty-php",
-- puppet-lint
["reorder-python-imports"] = "reorder-python-imports",
-- rescript-format
["rubocop"] = "rubocop",
["rubyfmt"] = "rubyfmt",
-- ruff
["ruff_fix"] = "ruff",
["ruff_format"] = "ruff",
["rufo"] = "rufo",
-- NOTE: Should install through rustup instead
-- ["rustfmt"] = "rustfmt",
["rustywind"] = "rustywind",
-- scalafmt
["shellcheck"] = "shellcheck",
["shellharden"] = "shellharden",
["shfmt"] = "shfmt",
["sql_formatter"] = "sql-formatter",
["sqlfluff"] = "sqlfluff",
["sqlfmt"] = "sqlfmt",
-- squeeze_blanks
["standardjs"] = "standardjs",
["standardrb"] = "standardrb",
["stylelint"] = "stylelint",
-- styler
["stylua"] = "stylua",
-- swift_format
-- swiftformat
["taplo"] = "taplo",
["templ"] = "templ",
-- terraform_fmt
-- terragrunt_hclfmt
["tlint"] = "tlint",
-- trim_newlines
-- trim_whitespace
-- twig-cs-fixer
["typos"] = "typos",
-- typstfmt
-- uncrustify
["usort"] = "usort",
["xmlformat"] = "xmlformatter",
-- xmllint
["yamlfix"] = "yamlfix",
["yamlfmt"] = "yamlfmt",
["yapf"] = "yapf",
["yq"] = "yq",
-- zigfmt
["zprint"] = "zprint",
}
local M = {}
function M.process_formatters(formatters_by_ft)
local formatters_to_install = {}
for _, formatters in pairs(formatters_by_ft) do
for _, formatter in pairs(formatters) do
if type(formatter) == "table" then
for _, f in pairs(formatter) do
local package = conform_to_mason[f]
if package ~= nil then
formatters_to_install[package] = 1
end
end
end
local package = conform_to_mason[formatter]
if package ~= nil then
formatters_to_install[package] = 1
end
end
end
return vim.tbl_keys(formatters_to_install)
end
return M