remove dottily config and fix deprecated nix options

This commit is contained in:
2026-06-12 21:30:41 +02:00
parent f7e1f95746
commit 1ac7fe8d35
6 changed files with 8 additions and 992 deletions
-1
View File
@@ -1 +0,0 @@
globals = { "vim" }
-461
View File
@@ -1,461 +0,0 @@
--
-- CONFIGS
--
vim.opt.termguicolors = true -- enable 24-bit RGB colors in the terminal
-- Line numbers
vim.opt.number = true -- show absolute line number on current line
vim.opt.relativenumber = true -- show relative line numbers for all other lines
vim.opt.cursorline = true -- highlight the row the cursor is on
vim.opt.wrap = false -- do not wrap long lines
vim.opt.scrolloff = 10 -- keep at least 10 lines above/below the cursor
vim.opt.sidescrolloff = 10 -- keep at least 10 columns left/right of the cursor
-- Indentation: 2-space soft tabs
vim.opt.tabstop = 2 -- a <Tab> counts as 2 columns
vim.opt.shiftwidth = 2 -- >> / << shift by 2 columns
vim.opt.softtabstop = 2 -- <Tab> in insert mode inserts 2 spaces
vim.opt.expandtab = true -- insert spaces instead of tab characters
vim.opt.smartindent = true
vim.opt.autoindent = true
-- Search
vim.opt.ignorecase = true -- case-insensitive search by default
vim.opt.smartcase = true -- switch to case-sensitive when query contains an uppercase letter
vim.opt.hlsearch = true -- highlight all matches
vim.opt.incsearch = true -- show matches while typing the query
-- UI
vim.opt.showmatch = true -- briefly jump to matching bracket when one is inserted
vim.opt.cmdheight = 1 -- always show the command line (1 row)
vim.opt.showmode = false -- hide "-- INSERT --" etc.; the statusline shows the mode instead
vim.opt.pumheight = 10 -- limit the completion popup to 10 items
vim.opt.pumblend = 10 -- make the completion popup slightly transparent
vim.opt.winblend = 0 -- floating windows are fully opaque
vim.opt.conceallevel = 0 -- never hide markup characters (e.g. Markdown asterisks)
vim.opt.concealcursor = "" -- never hide markup on the cursor line either
vim.opt.synmaxcol = 300 -- stop syntax highlighting for columns beyond 300 (perf guard)
vim.opt.fillchars = { eob = " " } -- replace the "~" placeholder on empty lines with a space
-- Persistent undo: survive across sessions even after the buffer is closed
local undodir = vim.fn.expand("~/.vim/undodir")
if
vim.fn.isdirectory(undodir) == 0 -- create undodir if nonexistent
then
vim.fn.mkdir(undodir, "p")
end
vim.opt.backup = false -- do not create a backup file
vim.opt.writebackup = false -- do not keep a backup while overwriting a file
vim.opt.swapfile = false -- do not create a swapfile
vim.opt.undofile = true -- persist undo history to disk
vim.opt.undodir = undodir -- where to store undo files
vim.opt.updatetime = 300 -- write swap file (and trigger CursorHold) after 300 ms of inactivity
vim.opt.timeoutlen = 500 -- wait 500 ms for a mapped key sequence to complete
vim.opt.ttimeoutlen = 50 -- wait 50 ms for a terminal key code to complete
vim.opt.autoread = true -- reload a file changed outside Neovim without prompting
vim.opt.autowrite = false -- do not silently save on :make / buffer switch
-- Buffer and editing behaviour
vim.opt.hidden = true -- allow switching away from an unsaved buffer without closing it
vim.opt.errorbells = false -- disable the error bell
vim.opt.backspace = "indent,eol,start" -- allow backspace over auto-indent, line breaks, and insert start
vim.opt.autochdir = false -- keep the working directory fixed (don't follow the open file)
vim.opt.iskeyword:append("-") -- treat "foo-bar" as a single word for motions like w/b
vim.opt.path:append("**") -- make :find search recursively into subdirectories
vim.opt.selection = "inclusive" -- visual selection includes the character under the cursor
vim.opt.mouse = "a" -- enable mouse support in all modes
vim.opt.clipboard:append("unnamedplus") -- share the system clipboard (+ register)
-- Over SSH, wl-clipboard is unavailable; use OSC 52 to write yanks to the local terminal clipboard.
if os.getenv("SSH_TTY") then
vim.g.clipboard = {
name = "OSC 52",
copy = {
["+"] = require("vim.ui.clipboard.osc52").copy("+"),
["*"] = require("vim.ui.clipboard.osc52").copy("*"),
},
paste = {
["+"] = require("vim.ui.clipboard.osc52").paste("+"),
["*"] = require("vim.ui.clipboard.osc52").paste("*"),
},
}
end
vim.opt.modifiable = true -- allow buffer modifications (safety default)
vim.opt.encoding = "utf-8" -- internal character encoding
-- Folding: driven by Tree-sitter when available; foldlevel = 99 means all folds start open
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt.foldlevel = 99 -- a high value ensures every fold is open on buffer load
-- Window splits
vim.opt.splitbelow = true -- :split opens the new window below
vim.opt.splitright = true -- :vsplit opens the new window to the right
-- Miscellaneous
vim.opt.wildmenu = true -- enable enhanced command-line completion
vim.opt.wildmode = "longest:full,full" -- first Tab completes the longest common prefix and lists all; subsequent Tabs cycle
vim.opt.diffopt:append("linematch:60") -- use the improved diff algorithm for blocks up to 60 lines
vim.opt.redrawtime = 10000 -- allow up to 10 s for a full screen redraw (useful for large files)
vim.opt.maxmempattern = 20000 -- raise the memory cap for pattern matching (avoids "pattern too complex" errors)
--
-- KEYMAPS
--
vim.g.mapleader = " " -- <Space> as the leader key
vim.g.maplocalleader = " " -- <Space> as the local leader key
-- j/k navigate display lines when there is no count prefix, so wrapped lines
-- feel natural. With a count (e.g. 5j) they use real lines so relative jumps work.
vim.keymap.set("n", "j", function()
return vim.v.count == 0 and "gj" or "j"
end, { expr = true, silent = true, desc = "Down (wrap-aware)" })
vim.keymap.set("n", "k", function()
return vim.v.count == 0 and "gk" or "k"
end, { expr = true, silent = true, desc = "Up (wrap-aware)" })
-- Keep search results and half-page jumps vertically centred
vim.keymap.set("n", "n", "nzzzv", { desc = "Next search result (centered)" })
vim.keymap.set("n", "N", "Nzzzv", { desc = "Previous search result (centered)" })
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Half page down (centered)" })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Half page up (centered)" })
-- Window navigation without the <C-w> prefix
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Move to left window" })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Move to bottom window" })
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Move to top window" })
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Move to right window" })
-- Re-select visual block after indent so you can keep indenting with < or >
vim.keymap.set("v", "<", "<gv", { desc = "Indent left and reselect" })
vim.keymap.set("v", ">", ">gv", { desc = "Indent right and reselect" })
-- J joins lines but restores the cursor position (mz saves, `z restores)
vim.keymap.set("n", "J", "mzJ`z", { desc = "Join lines and keep cursor position" })
vim.keymap.set("n", "H", "<cmd>bprev<cr>", { desc = "Previous buffer" })
vim.keymap.set("n", "L", "<cmd>bnext<cr>", { desc = "Next buffer" })
-- Toggle LSP diagnostics on/off for the current session
vim.keymap.set("n", "<leader>td", function()
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
end, { desc = "Toggle diagnostics" })
-- Toggle inline virtual text only (keeps underlines and signs)
vim.keymap.set("n", "<leader>tv", function()
local current = vim.diagnostic.config().virtual_text
vim.diagnostic.config({ virtual_text = not current })
end, { desc = "Toggle virtual text" })
--
-- AUTOCOMMANDS
--
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = true })
-- Format on save via the EFM language server.
-- Only runs when: the buffer is a real file, it is modifiable, it has a name,
-- and efm is attached. This avoids spurious save prompts on scratch buffers.
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
pattern = {
"*.cs",
"*.lua",
"*.py",
"*.go",
"*.js",
"*.jsx",
"*.ts",
"*.tsx",
"*.json",
"*.css",
"*.scss",
"*.html",
"*.sh",
"*.bash",
},
callback = function(args)
-- avoid formatting non-file buffers (helps prevent weird write prompts)
if vim.bo[args.buf].buftype ~= "" then
return
end
if not vim.bo[args.buf].modifiable then
return
end
if vim.api.nvim_buf_get_name(args.buf) == "" then
return
end
local has_efm = false
for _, c in ipairs(vim.lsp.get_clients({ bufnr = args.buf })) do
if c.name == "efm" then
has_efm = true
break
end
end
if not has_efm then
return
end
pcall(vim.lsp.buf.format, {
bufnr = args.buf,
timeout_ms = 2000,
filter = function(c)
return c.name == "efm"
end,
})
end,
})
-- Flash the yanked region briefly so it is clear what was copied
vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup,
callback = function()
vim.hl.on_yank()
end,
})
-- Restore the cursor to where it was when the file was last closed
vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup,
desc = "Restore last cursor position",
callback = function()
if vim.o.diff then -- except in diff mode
return
end
local last_pos = vim.api.nvim_buf_get_mark(0, '"') -- {line, col}
local last_line = vim.api.nvim_buf_line_count(0)
local row = last_pos[1]
if row < 1 or row > last_line then
return
end
pcall(vim.api.nvim_win_set_cursor, 0, last_pos)
end,
})
-- Prose-friendly settings for Markdown, plain text, and commit messages
vim.api.nvim_create_autocmd("FileType", {
group = augroup,
pattern = { "markdown", "text", "gitcommit" },
callback = function()
vim.opt_local.wrap = true -- soft-wrap at window edge
vim.opt_local.linebreak = true -- break at word boundaries, not mid-word
vim.opt_local.spell = true -- enable spell-checking
end,
})
--
-- PLUGINS
--
vim.pack.add({
"https://github.com/folke/which-key.nvim", -- shows pending keymap hints
"https://github.com/folke/tokyonight.nvim", -- colorscheme
"https://github.com/nvim-lualine/lualine.nvim", -- statusline
"https://www.github.com/lewis6991/gitsigns.nvim", -- git hunk signs in the gutter
"https://www.github.com/echasnovski/mini.nvim", -- collection of small plugins
"https://www.github.com/ibhagwan/fzf-lua", -- fuzzy finder (files, grep, LSP, …)
"https://www.github.com/neovim/nvim-lspconfig", -- provides cmd/root_dir/filetypes for each LSP server
"https://github.com/mason-org/mason.nvim", -- LSP / tool installer UI
"https://github.com/creativenull/efmls-configs-nvim", -- pre-built efm-langserver tool configs
"https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim", -- auto-install Mason tools on startup
"https://github.com/folke/flash.nvim", -- enhanced f/t/s jumps with labels
"https://github.com/L3MON4D3/LuaSnip", -- snippet engine (used by blink.cmp)
{
src = "https://github.com/saghen/blink.cmp", -- completion engine
version = vim.version.range("1.*"), -- pin to any 1.x release
},
{
src = "https://github.com/nvim-treesitter/nvim-treesitter",
branch = "main",
build = ":TSUpdate", -- keep parser binaries up to date after install/update
},
"https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
"https://github.com/HakonHarnes/img-clip.nvim", -- paste images from clipboard (no Python required)
})
--
-- PLUGIN CONFIGS
--
require("lualine").setup()
vim.cmd.colorscheme("tokyonight")
-- which-key: shows a popup of available keymaps after a delay.
-- Groups give the prefixes human-readable titles in the popup.
require("which-key").setup({})
require("which-key").add({
{ "<leader>f", group = "Find" }, -- fzf-lua pickers (files, grep, LSP symbols, …)
{ "<leader>g", group = "Go to" }, -- LSP navigation (definition, split, …)
{ "<leader>c", group = "Code" }, -- code actions
{ "<leader>r", group = "Refactor" }, -- rename, extract, …
{ "<leader>t", group = "Toggle" }, -- toggle settings (diagnostics, …)
{ "<leader>o", group = "Organize" }, -- organize imports, sort, …
{ "<leader>d", group = "Diagnostics" }, -- diagnostic float / list
{ "<leader>n", group = "Next" }, -- jump to next item
{ "<leader>p", group = "Prev" }, -- jump to previous item
{ "]m", hidden = true },
{ "[m", hidden = true },
{ "]M", hidden = true },
{ "[M", hidden = true },
})
-- Tree-sitter: start the parser for a filetype only when its grammar is
-- already installed. Missing grammars are installed asynchronously on first
-- launch so the editor never blocks at startup.
local setup_treesitter = function()
local treesitter = require("nvim-treesitter")
treesitter.setup({})
local ensure_installed = {
"vim",
"vimdoc",
"go",
"html",
"css",
"javascript",
"json",
"lua",
"markdown",
"python",
"typescript",
"bash",
"c_sharp",
}
local config = require("nvim-treesitter.config")
-- Only install parsers that are not already present
local already_installed = config.get_installed()
local parsers_to_install = {}
for _, parser in ipairs(ensure_installed) do
if not vim.tbl_contains(already_installed, parser) then
table.insert(parsers_to_install, parser)
end
end
if #parsers_to_install > 0 then
treesitter.install(parsers_to_install)
end
-- Start the Tree-sitter parser whenever a supported filetype is opened.
-- Using an autocmd instead of the built-in auto_install avoids the
-- blocking install prompt on first open.
local group = vim.api.nvim_create_augroup("TreeSitterConfig", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = group,
callback = function(args)
if vim.list_contains(treesitter.get_installed(), vim.treesitter.language.get_lang(args.match)) then
vim.treesitter.start(args.buf)
end
end,
})
end
setup_treesitter()
require("nvim-treesitter-textobjects").setup({ move = { set_jumps = true } })
local move = require("nvim-treesitter-textobjects.move")
vim.keymap.set({ "n", "x", "o" }, "]f", function()
move.goto_next_start("@function.outer", "textobjects")
end, { desc = "Next function" })
vim.keymap.set({ "n", "x", "o" }, "[f", function()
move.goto_previous_start("@function.outer", "textobjects")
end, { desc = "Prev function" })
vim.keymap.set({ "n", "x", "o" }, "]c", function()
move.goto_next_start("@class.outer", "textobjects")
end, { desc = "Next class" })
vim.keymap.set({ "n", "x", "o" }, "[c", function()
move.goto_previous_start("@class.outer", "textobjects")
end, { desc = "Prev class" })
-- fzf-lua: fuzzy finder keymaps
require("fzf-lua").setup({
files = {
actions = {
["ctrl-h"] = { require("fzf-lua").actions.toggle_hidden },
},
},
})
vim.keymap.set("n", "<leader><leader>", function()
require("fzf-lua").files()
end, { desc = "Find files" })
vim.keymap.set("n", "<leader>fg", function()
require("fzf-lua").live_grep()
end, { desc = "FZF Live Grep" })
vim.keymap.set("n", "<leader>fb", function()
require("fzf-lua").buffers()
end, { desc = "FZF Buffers" })
vim.keymap.set("n", "<leader>fh", function()
require("fzf-lua").help_tags()
end, { desc = "FZF Help Tags" })
vim.keymap.set("n", "<leader>fx", function()
require("fzf-lua").diagnostics_document()
end, { desc = "FZF Diagnostics Document" })
vim.keymap.set("n", "<leader>fX", function()
require("fzf-lua").diagnostics_workspace()
end, { desc = "FZF Diagnostics Workspace" })
-- mini.nvim: a suite of small, focused plugins. Each module is opted in explicitly.
require("mini.ai").setup({}) -- extended text objects (e.g. cia = inside any argument)
require("mini.comment").setup({}) -- gcc / gc<motion> to toggle comments
require("mini.move").setup({}) -- move lines/selections with Option+hjkl (macOS Option = Alt)
require("mini.surround").setup({}) -- sa/sd/sr to add/delete/replace surrounding chars
require("mini.cursorword").setup({}) -- highlight all occurrences of the word under the cursor
require("mini.indentscope").setup({}) -- animated indent-scope indicator line
require("mini.pairs").setup({}) -- auto-close brackets, quotes, etc.
require("mini.trailspace").setup({}) -- highlight and trim trailing whitespace
require("mini.notify").setup({}) -- non-blocking notification popups
require("mini.icons").setup({}) -- icon provider (replaces nvim-web-devicons calls)
-- flash.nvim: label-based jumps for f/t and anywhere on screen
require("flash").setup({})
vim.keymap.set({ "n", "x", "o" }, "s", function()
require("flash").jump()
end, { desc = "Flash jump" })
vim.keymap.set({ "n", "x", "o" }, "S", function()
require("flash").treesitter()
end, { desc = "Flash treesitter" })
vim.keymap.set("o", "r", function()
require("flash").remote()
end, { desc = "Flash remote" })
vim.keymap.set({ "o", "x" }, "R", function()
require("flash").treesitter_search()
end, { desc = "Flash treesitter search" })
-- img-clip: paste images from clipboard into markdown files (no Python required)
require("img-clip").setup({
default = {
use_absolute_path = false,
relative_to_current_file = true,
file_name = function()
return os.date("%Y-%m-%d_%H-%M-%S")
end,
},
filetypes = {
markdown = { template = "![]($FILE_PATH)" },
},
})
vim.keymap.set({ "n", "x" }, "<leader>pi", "<cmd>PasteImage<CR>", { desc = "Paste image" })
-- gitsigns: decorates the sign column with added/changed/removed hunk markers
require("gitsigns").setup({
signs = {
add = { text = "\u{2590}" }, -- ▏
change = { text = "\u{2590}" }, -- ▐
delete = { text = "\u{2590}" }, -- ◦
topdelete = { text = "\u{25e6}" }, -- ◦
changedelete = { text = "\u{25cf}" }, -- ●
untracked = { text = "\u{25cb}" }, -- ○
},
signcolumn = true,
current_line_blame = false, -- set to true to show inline git blame on the cursor line
})
--
-- LSP - Too anoying to have in this file
--
require("lsp-nix")
-211
View File
@@ -1,211 +0,0 @@
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = false })
-- Diagnostic icons shown in the sign column and virtual text
local diagnostic_signs = {
Error = " ",
Warn = " ",
Hint = "",
Info = "",
}
-- Global diagnostic display options
vim.diagnostic.config({
virtual_text = { prefix = "", spacing = 4 }, -- inline diagnostic text to the right
signs = {
text = {
[vim.diagnostic.severity.ERROR] = diagnostic_signs.Error,
[vim.diagnostic.severity.WARN] = diagnostic_signs.Warn,
[vim.diagnostic.severity.INFO] = diagnostic_signs.Info,
[vim.diagnostic.severity.HINT] = diagnostic_signs.Hint,
},
},
underline = true,
update_in_insert = false, -- do not update diagnostics while typing (reduces noise)
severity_sort = true, -- show errors before warnings in lists
float = {
border = "rounded",
source = "always", -- always show which LSP server produced the diagnostic
header = "",
prefix = "",
focusable = false,
style = "minimal",
},
})
-- Patch vim.lsp.util.open_floating_preview so every LSP floating window
-- (hover, signature help, etc.) gets a rounded border without having to
-- configure it per-server.
do
local orig = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or "rounded"
return orig(contents, syntax, opts, ...)
end
end
-- lsp_on_attach is called whenever an LSP server attaches to a buffer.
-- It sets up buffer-local keymaps that are only active when an LSP is present.
local function lsp_on_attach(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if not client then
return
end
local bufnr = ev.buf
local function map(key, fn, desc)
vim.keymap.set("n", key, fn, { noremap = true, silent = true, buffer = bufnr, desc = desc })
end
-- Navigation
map("<leader>gd", vim.lsp.buf.definition, "Go to definition")
map("<leader>gS", function() vim.cmd("vsplit") vim.lsp.buf.definition() end, "Go to definition (vsplit)")
-- Code actions and refactoring
map("<leader>ca", vim.lsp.buf.code_action, "Code action")
map("<leader>rn", vim.lsp.buf.rename, "Rename symbol")
-- Diagnostics
map("<leader>D", function() vim.diagnostic.open_float({ scope = "line" }) end, "Line diagnostics")
map("<leader>d", function() vim.diagnostic.open_float({ scope = "cursor" }) end, "Cursor diagnostic")
map("<leader>nd", function() vim.diagnostic.jump({ count = 1 }) end, "Next diagnostic")
map("<leader>pd", function() vim.diagnostic.jump({ count = -1 }) end, "Prev diagnostic")
-- Hover documentation
map("K", vim.lsp.buf.hover, "Hover docs")
-- fzf-lua LSP pickers
map("<leader>fd", function() require("fzf-lua").lsp_definitions({ jump_to_single_result = true }) end, "Definitions")
map("<leader>fr", function() require("fzf-lua").lsp_references() end, "References")
map("<leader>ft", function() require("fzf-lua").lsp_typedefs() end, "Type definitions")
map("<leader>fs", function() require("fzf-lua").lsp_document_symbols() end, "Document symbols")
map("<leader>fw", function() require("fzf-lua").lsp_workspace_symbols() end, "Workspace symbols")
map("<leader>fi", function() require("fzf-lua").lsp_implementations() end, "Implementations")
-- Organise imports then format (only registered when the server supports codeAction)
if client:supports_method("textDocument/codeAction", bufnr) then
map("<leader>oi", function()
vim.lsp.buf.code_action({
context = { only = { "source.organizeImports" }, diagnostics = {} },
apply = true,
bufnr = bufnr,
})
-- Small delay lets the import action settle before formatting
vim.defer_fn(function()
vim.lsp.buf.format({ bufnr = bufnr })
end, 50)
end, "Organize imports")
end
end
vim.api.nvim_create_autocmd("LspAttach", { group = augroup, callback = lsp_on_attach })
-- Global diagnostic keymaps (available without an LSP attached)
vim.keymap.set("n", "<leader>q", function() vim.diagnostic.setloclist({ open = true }) end, { desc = "Open diagnostic list" })
-- blink.cmp: completion engine wired to LuaSnip for snippet expansion
require("blink.cmp").setup({
enabled = function()
return not vim.tbl_contains({ "markdown", "text" }, vim.bo.filetype)
end,
keymap = {
preset = "none", -- start from a blank slate; all bindings are explicit
["<C-Space>"] = { "show", "hide" }, -- toggle the completion menu
["<CR>"] = { "accept", "fallback" }, -- confirm selection
["<C-j>"] = { "select_next", "fallback" },
["<C-k>"] = { "select_prev", "fallback" },
["<Tab>"] = { "snippet_forward", "fallback" }, -- jump to next snippet placeholder
["<S-Tab>"] = { "snippet_backward", "fallback" }, -- jump to previous placeholder
},
appearance = { nerd_font_variant = "mono" },
completion = { menu = { auto_show = true } }, -- show the menu automatically (no manual trigger needed)
sources = { default = { "lsp", "path", "buffer", "snippets" } },
snippets = {
-- Delegate snippet expansion to LuaSnip
expand = function(snippet)
require("luasnip").lsp_expand(snippet)
end,
},
fuzzy = {
implementation = "prefer_rust", -- use the faster Rust fuzzy-matching backend when available
prebuilt_binaries = { download = true }, -- automatically download the pre-built binary
},
})
-- Inject blink.cmp capabilities into every LSP server so they can offer
-- completions that respect snippet and LSP-specific completion item fields
vim.lsp.config["*"] = {
capabilities = require("blink.cmp").get_lsp_capabilities(),
}
-- Server configurations
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = { globals = { "vim" } }, -- teach lua_ls that `vim` is a known global
telemetry = { enable = false },
},
},
})
vim.lsp.config("pyright", {}) -- Python type checker and language server
vim.lsp.config("bashls", {}) -- Bash language server
vim.lsp.config("vtsls", {}) -- TypeScript / JavaScript language server (VS Code's TS server)
vim.lsp.config("gopls", {}) -- Go language server
vim.lsp.config("omnisharp", {}) -- C# language server
-- EFM (efm-langserver): a generic LSP adapter that runs command-line linters
-- and formatters and exposes them as LSP capabilities.
do
local luacheck = require("efmls-configs.linters.luacheck")
local stylua = require("efmls-configs.formatters.stylua")
local flake8 = require("efmls-configs.linters.flake8")
local black = require("efmls-configs.formatters.black")
local prettier_d = require("efmls-configs.formatters.prettier_d")
local eslint_d = require("efmls-configs.linters.eslint_d")
local fixjson = require("efmls-configs.formatters.fixjson")
local shellcheck = require("efmls-configs.linters.shellcheck")
local shfmt = require("efmls-configs.formatters.shfmt")
local go_revive = require("efmls-configs.linters.go_revive")
local gofumpt = require("efmls-configs.formatters.gofumpt")
local csharpier = { formatCommand = "dotnet csharpier --write-stdout", formatStdin = true }
vim.lsp.config("efm", {
filetypes = {
"cs", "css", "go", "html",
"javascript", "javascriptreact",
"json", "jsonc",
"lua", "markdown", "python", "sh",
"typescript", "typescriptreact",
},
init_options = { documentFormatting = true },
settings = {
languages = {
cs = { csharpier },
go = { gofumpt, go_revive },
css = { prettier_d },
html = { prettier_d },
javascript = { eslint_d, prettier_d },
javascriptreact = { eslint_d, prettier_d },
json = { eslint_d, fixjson },
jsonc = { eslint_d, fixjson },
lua = { luacheck, stylua },
markdown = { prettier_d },
python = { flake8, black },
sh = { shellcheck, shfmt },
typescript = { eslint_d, prettier_d },
typescriptreact = { eslint_d, prettier_d },
},
},
})
end
-- Start all configured LSP servers
vim.lsp.enable({
"lua_ls",
"pyright",
"bashls",
"vtsls",
"gopls",
"omnisharp",
"efm",
})
-242
View File
@@ -1,242 +0,0 @@
-- mason: GUI for installing LSP servers, DAPs, linters and formatters
require("mason").setup({})
-- mason-tool-installer: automatically install all required tools on startup
require("mason-tool-installer").setup({
ensure_installed = {
-- LSP servers
"lua-language-server",
"pyright",
"bash-language-server",
"vtsls",
"gopls",
"omnisharp",
"efm",
-- Formatters
"stylua",
"black",
"prettierd",
"shfmt",
"gofumpt",
"fixjson",
-- Linters
"flake8",
"eslint_d",
"shellcheck",
"revive",
},
auto_update = false,
run_on_start = true,
})
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = false })
-- Diagnostic icons shown in the sign column and virtual text
local diagnostic_signs = {
Error = " ",
Warn = " ",
Hint = "",
Info = "",
}
-- Global diagnostic display options
vim.diagnostic.config({
virtual_text = { prefix = "", spacing = 4 }, -- inline diagnostic text to the right
signs = {
text = {
[vim.diagnostic.severity.ERROR] = diagnostic_signs.Error,
[vim.diagnostic.severity.WARN] = diagnostic_signs.Warn,
[vim.diagnostic.severity.INFO] = diagnostic_signs.Info,
[vim.diagnostic.severity.HINT] = diagnostic_signs.Hint,
},
},
underline = true,
update_in_insert = false, -- do not update diagnostics while typing (reduces noise)
severity_sort = true, -- show errors before warnings in lists
float = {
border = "rounded",
source = "always", -- always show which LSP server produced the diagnostic
header = "",
prefix = "",
focusable = false,
style = "minimal",
},
})
-- Patch vim.lsp.util.open_floating_preview so every LSP floating window
-- (hover, signature help, etc.) gets a rounded border without having to
-- configure it per-server.
do
local orig = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or "rounded"
return orig(contents, syntax, opts, ...)
end
end
-- lsp_on_attach is called whenever an LSP server attaches to a buffer.
-- It sets up buffer-local keymaps that are only active when an LSP is present.
local function lsp_on_attach(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if not client then
return
end
local bufnr = ev.buf
local function map(key, fn, desc)
vim.keymap.set("n", key, fn, { noremap = true, silent = true, buffer = bufnr, desc = desc })
end
-- Navigation
map("<leader>gd", vim.lsp.buf.definition, "Go to definition")
map("<leader>gS", function() vim.cmd("vsplit") vim.lsp.buf.definition() end, "Go to definition (vsplit)")
-- Code actions and refactoring
map("<leader>ca", vim.lsp.buf.code_action, "Code action")
map("<leader>rn", vim.lsp.buf.rename, "Rename symbol")
-- Diagnostics
map("<leader>D", function() vim.diagnostic.open_float({ scope = "line" }) end, "Line diagnostics")
map("<leader>d", function() vim.diagnostic.open_float({ scope = "cursor" }) end, "Cursor diagnostic")
map("<leader>nd", function() vim.diagnostic.jump({ count = 1 }) end, "Next diagnostic")
map("<leader>pd", function() vim.diagnostic.jump({ count = -1 }) end, "Prev diagnostic")
-- Hover documentation
map("K", vim.lsp.buf.hover, "Hover docs")
-- fzf-lua LSP pickers
map("<leader>fd", function() require("fzf-lua").lsp_definitions({ jump_to_single_result = true }) end, "Definitions")
map("<leader>fr", function() require("fzf-lua").lsp_references() end, "References")
map("<leader>ft", function() require("fzf-lua").lsp_typedefs() end, "Type definitions")
map("<leader>fs", function() require("fzf-lua").lsp_document_symbols() end, "Document symbols")
map("<leader>fw", function() require("fzf-lua").lsp_workspace_symbols() end, "Workspace symbols")
map("<leader>fi", function() require("fzf-lua").lsp_implementations() end, "Implementations")
-- Organise imports then format (only registered when the server supports codeAction)
if client:supports_method("textDocument/codeAction", bufnr) then
map("<leader>oi", function()
vim.lsp.buf.code_action({
context = { only = { "source.organizeImports" }, diagnostics = {} },
apply = true,
bufnr = bufnr,
})
-- Small delay lets the import action settle before formatting
vim.defer_fn(function()
vim.lsp.buf.format({ bufnr = bufnr })
end, 50)
end, "Organize imports")
end
end
vim.api.nvim_create_autocmd("LspAttach", { group = augroup, callback = lsp_on_attach })
-- Global diagnostic keymaps (available without an LSP attached)
vim.keymap.set("n", "<leader>q", function() vim.diagnostic.setloclist({ open = true }) end, { desc = "Open diagnostic list" })
-- blink.cmp: completion engine wired to LuaSnip for snippet expansion
require("blink.cmp").setup({
enabled = function()
return not vim.tbl_contains({ "markdown", "text" }, vim.bo.filetype)
end,
keymap = {
preset = "none", -- start from a blank slate; all bindings are explicit
["<C-Space>"] = { "show", "hide" }, -- toggle the completion menu
["<CR>"] = { "accept", "fallback" }, -- confirm selection
["<C-j>"] = { "select_next", "fallback" },
["<C-k>"] = { "select_prev", "fallback" },
["<Tab>"] = { "snippet_forward", "fallback" }, -- jump to next snippet placeholder
["<S-Tab>"] = { "snippet_backward", "fallback" }, -- jump to previous placeholder
},
appearance = { nerd_font_variant = "mono" },
completion = { menu = { auto_show = true } }, -- show the menu automatically (no manual trigger needed)
sources = { default = { "lsp", "path", "buffer", "snippets" } },
snippets = {
-- Delegate snippet expansion to LuaSnip
expand = function(snippet)
require("luasnip").lsp_expand(snippet)
end,
},
fuzzy = {
implementation = "prefer_rust", -- use the faster Rust fuzzy-matching backend when available
prebuilt_binaries = { download = true }, -- automatically download the pre-built binary
},
})
-- Inject blink.cmp capabilities into every LSP server so they can offer
-- completions that respect snippet and LSP-specific completion item fields
vim.lsp.config["*"] = {
capabilities = require("blink.cmp").get_lsp_capabilities(),
}
-- Server configurations
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = { globals = { "vim" } }, -- teach lua_ls that `vim` is a known global
telemetry = { enable = false },
},
},
})
vim.lsp.config("pyright", {}) -- Python type checker and language server
vim.lsp.config("bashls", {}) -- Bash language server
vim.lsp.config("vtsls", {}) -- TypeScript / JavaScript language server (VS Code's TS server)
vim.lsp.config("gopls", {}) -- Go language server
vim.lsp.config("omnisharp", {}) -- C# language server
-- EFM (efm-langserver): a generic LSP adapter that runs command-line linters
-- and formatters and exposes them as LSP capabilities.
do
local luacheck = require("efmls-configs.linters.luacheck")
local stylua = require("efmls-configs.formatters.stylua")
local flake8 = require("efmls-configs.linters.flake8")
local black = require("efmls-configs.formatters.black")
local prettier_d = require("efmls-configs.formatters.prettier_d")
local eslint_d = require("efmls-configs.linters.eslint_d")
local fixjson = require("efmls-configs.formatters.fixjson")
local shellcheck = require("efmls-configs.linters.shellcheck")
local shfmt = require("efmls-configs.formatters.shfmt")
local go_revive = require("efmls-configs.linters.go_revive")
local gofumpt = require("efmls-configs.formatters.gofumpt")
local csharpier = { formatCommand = "dotnet csharpier --write-stdout", formatStdin = true }
vim.lsp.config("efm", {
filetypes = {
"cs", "css", "go", "html",
"javascript", "javascriptreact",
"json", "jsonc",
"lua", "markdown", "python", "sh",
"typescript", "typescriptreact",
},
init_options = { documentFormatting = true },
settings = {
languages = {
cs = { csharpier },
go = { gofumpt, go_revive },
css = { prettier_d },
html = { prettier_d },
javascript = { eslint_d, prettier_d },
javascriptreact = { eslint_d, prettier_d },
json = { eslint_d, fixjson },
jsonc = { eslint_d, fixjson },
lua = { luacheck, stylua },
markdown = { prettier_d },
python = { flake8, black },
sh = { shellcheck, shfmt },
typescript = { eslint_d, prettier_d },
typescriptreact = { eslint_d, prettier_d },
},
},
})
end
-- Start all configured LSP servers
vim.lsp.enable({
"lua_ls",
"pyright",
"bashls",
"vtsls",
"gopls",
"omnisharp",
"efm",
})
-69
View File
@@ -1,69 +0,0 @@
{
"plugins": {
"LuaSnip": {
"rev": "a62e1083a3cfe8b6b206e7d3d33a51091df25357",
"src": "https://github.com/L3MON4D3/LuaSnip"
},
"blink.cmp": {
"rev": "78336bc89ee5365633bcf754d93df01678b5c08f",
"src": "https://github.com/saghen/blink.cmp",
"version": "1.0.0 - 2.0.0"
},
"efmls-configs-nvim": {
"rev": "5dc52088c231f2721f545570fcb541b04802ce6b",
"src": "https://github.com/creativenull/efmls-configs-nvim"
},
"flash.nvim": {
"rev": "fcea7ff883235d9024dc41e638f164a450c14ca2",
"src": "https://github.com/folke/flash.nvim"
},
"fzf-lua": {
"rev": "657c1bbb7357c61e26a20d868b53a460b05c18c0",
"src": "https://www.github.com/ibhagwan/fzf-lua"
},
"gitsigns.nvim": {
"rev": "8d82c240f190fc33723d48c308ccc1ed8baad69d",
"src": "https://www.github.com/lewis6991/gitsigns.nvim"
},
"img-clip.nvim": {
"rev": "b6ddfb97b5600d99afe3452d707444afda658aca",
"src": "https://github.com/HakonHarnes/img-clip.nvim"
},
"lualine.nvim": {
"rev": "a905eeebc4e63fdc48b5135d3bf8aea5618fb21c",
"src": "https://github.com/nvim-lualine/lualine.nvim"
},
"mason-tool-installer.nvim": {
"rev": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc",
"src": "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim"
},
"mason.nvim": {
"rev": "b03fb0f20bc1d43daf558cda981a2be22e73ac42",
"src": "https://github.com/mason-org/mason.nvim"
},
"mini.nvim": {
"rev": "4182d64727fb4876407af65c181b85428a4a70d1",
"src": "https://www.github.com/echasnovski/mini.nvim"
},
"nvim-lspconfig": {
"rev": "cb5bc0b2b35a6d513e3298d285db81453e791f4f",
"src": "https://www.github.com/neovim/nvim-lspconfig"
},
"nvim-treesitter": {
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
},
"nvim-treesitter-textobjects": {
"rev": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e",
"src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"
},
"tokyonight.nvim": {
"rev": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6",
"src": "https://github.com/folke/tokyonight.nvim"
},
"which-key.nvim": {
"rev": "3aab2147e74890957785941f0c1ad87d0a44c15a",
"src": "https://github.com/folke/which-key.nvim"
}
}
}