-- Plugins are installed by Nix (see default.nix); this file only configures them. vim.g.mapleader = " " vim.g.maplocalleader = " " ----------------- ---- OPTIONS ---- ----------------- local o = vim.opt o.number = true o.relativenumber = true o.signcolumn = "yes" o.cursorline = true o.termguicolors = true o.mouse = "a" o.clipboard = "unnamedplus" o.undofile = true o.ignorecase = true o.smartcase = true o.splitright = true o.splitbelow = true o.scrolloff = 8 o.updatetime = 250 o.timeoutlen = 400 o.expandtab = true o.shiftwidth = 2 o.tabstop = 2 o.smartindent = true o.wrap = false o.list = true o.listchars = { tab = "» ", trail = "·", nbsp = "␣" } o.inccommand = "split" --------------------- ---- COLORSCHEME ---- --------------------- require("catppuccin").setup({ flavour = "mocha" }) vim.cmd.colorscheme("catppuccin") require("nvim-web-devicons").setup() require("lualine").setup({ options = { theme = "catppuccin-mocha", globalstatus = true } }) require("gitsigns").setup() require("which-key").setup() require("oil").setup() -- mini.nvim: only the small editing helpers. require("mini.pairs").setup() require("mini.surround").setup() -------------------- ---- TREESITTER ---- -------------------- -- Parsers come from nvim-treesitter.withAllGrammars. Starting the built-in -- highlighter works with both the old and the rewritten nvim-treesitter. vim.api.nvim_create_autocmd("FileType", { callback = function(args) pcall(vim.treesitter.start, args.buf) end, }) -------------------- ---- TELESCOPE ---- -------------------- local telescope = require("telescope") telescope.setup({}) pcall(telescope.load_extension, "fzf") local builtin = require("telescope.builtin") vim.keymap.set("n", "ff", builtin.find_files, { desc = "Find files" }) vim.keymap.set("n", "fg", builtin.live_grep, { desc = "Grep" }) vim.keymap.set("n", "fb", builtin.buffers, { desc = "Buffers" }) vim.keymap.set("n", "fh", builtin.help_tags, { desc = "Help" }) vim.keymap.set("n", "fr", builtin.oldfiles, { desc = "Recent files" }) vim.keymap.set("n", "-", "Oil", { desc = "File explorer" }) ------------- ---- LSP ---- ------------- -- Neovim 0.11+ API. nvim-lspconfig supplies the default cmd, filetypes and -- root markers for each server; the language servers are on nvim's PATH -- (extraPackages in default.nix). require("blink.cmp").setup({ keymap = { preset = "default" }, sources = { default = { "lsp", "path", "snippets", "buffer" } }, }) vim.lsp.config("*", { capabilities = require("blink.cmp").get_lsp_capabilities(), }) vim.lsp.config("nixd", { settings = { nixd = { formatting = { command = { "nixfmt" } }, }, }, }) vim.lsp.config("lua_ls", { settings = { Lua = { runtime = { version = "LuaJIT" }, diagnostics = { globals = { "vim", "hl" } }, workspace = { checkThirdParty = false }, telemetry = { enable = false }, }, }, }) vim.lsp.enable({ "nixd", "lua_ls", "bashls" }) vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) local function map(lhs, rhs, desc) vim.keymap.set("n", lhs, rhs, { buffer = args.buf, desc = desc }) end map("gd", vim.lsp.buf.definition, "Go to definition") map("gr", vim.lsp.buf.references, "References") map("K", vim.lsp.buf.hover, "Hover") map("rn", vim.lsp.buf.rename, "Rename") map("ca", vim.lsp.buf.code_action, "Code action") map("e", vim.diagnostic.open_float, "Line diagnostics") end, }) vim.diagnostic.config({ virtual_text = true, severity_sort = true }) ----------------------- ---- FORMAT ON SAVE ---- ----------------------- require("conform").setup({ formatters_by_ft = { nix = { "nixfmt" }, lua = { "stylua" }, sh = { "shfmt" }, bash = { "shfmt" }, }, format_on_save = { timeout_ms = 1000, lsp_format = "fallback", }, })