--- @diagnostic disable: missing-fields -- disables annoying warnings -- Must happen before plugins are required vim.g.mapleader = " " vim.g.maplocalleader = " " require("angryluck.options") require("angryluck.keymaps") require("angryluck.commands") -- [[ Install lazy.nvim ]] local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release lazypath, }) end vim.opt.runtimepath:prepend(lazypath) -- [[ Plugins ]] -- TODO: require("lazy").setup("angryluck.plugins") require("lazy").setup({ -- Detect tabstop and shiftwidth automatically -- Don't like this... -- "tpope/vim-sleuth", -- "gc" to comment visual regions/lines { "numToStr/Comment.nvim", opts = {} }, -- Git related plugins "tpope/vim-fugitive", "tpope/vim-rhubarb", { "lewis6991/gitsigns.nvim", opts = { signs = { add = { text = "+" }, change = { text = "~" }, delete = { text = "_" }, topdelete = { text = "‾" }, changedelete = { text = "~" }, }, }, }, { -- Shows pending keybinds "folke/which-key.nvim", event = "VimEnter", config = function() require("which-key").setup({ -- Remove this if so many keymaps, that you need to scroll popup_mappings = { scroll_down = "", scroll_up = "", }, -- Doesn't work -- trigger_blacklist = { -- v = { "j", "k", "", "" }, -- }, }) -- Document existing key chains require("which-key").register({ -- Naming leader-key-groups ["c"] = { name = "[C]ode", _ = "which_key_ignore" }, ["d"] = { name = "[D]ocument", _ = "which_key_ignore" }, ["r"] = { name = "[R]ename", _ = "which_key_ignore" }, ["s"] = { name = "[S]earch", _ = "which_key_ignore" }, ["w"] = { name = "[W]orkspace", _ = "which_key_ignore" }, ["o"] = { name = "[O]rgmode", _ = "which_key_ignore" }, }) end, }, -- Fuzzy Finder (files, lsp, etc) { "nvim-telescope/telescope.nvim", event = "VimEnter", branch = "0.1.x", dependencies = { { "nvim-lua/plenary.nvim" }, { -- If encountering errors, see telescope-fzf-native README "nvim-telescope/telescope-fzf-native.nvim", build = "make", cond = function() return vim.fn.executable("make") == 1 end, }, { "nvim-telescope/telescope-ui-select.nvim" }, { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, { "xiyaowong/telescope-emoji.nvim" }, }, config = function() require("telescope").setup({ defaults = { mappings = { i = { [""] = "to_fuzzy_refine" }, }, }, extensions = { ["ui-select"] = { require("telescope.themes").get_dropdown(), }, }, }) -- Enable telescope fzf native, if installed pcall(require("telescope").load_extension, "fzf") pcall(require("telescope").load_extension, "ui-select") require("telescope").load_extension("emoji") -- See `:help telescope.builtin` local builtin = require("telescope.builtin") vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp" }) vim.keymap.set("n", "sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" }) vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) vim.keymap.set("n", "ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" }) vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]esume" }) vim.keymap.set("n", "s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set("n", "sg", builtin.git_files, { desc = "[S]earch [G]it Files" }) vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) vim.keymap.set("n", "se", ":Telescope emoji", { desc = "[S]earch [E]mojis" }) -- Overriding default behavior and theme vim.keymap.set("n", "/", function() -- You can pass additional configuration to telescope to change theme, layout, etc. builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ winblend = 10, previewer = false, })) end, { desc = "[/] Fuzzily search in current buffer" }) -- Also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys vim.keymap.set("n", "s/", function() builtin.live_grep({ grep_open_files = true, prompt_title = "Live Grep in Open Files", }) end, { desc = "[S]earch [/] in Open Files" }) vim.keymap.set("n", "sn", function() builtin.find_files({ cwd = vim.fn.stdpath("config") }) end, { desc = "[S]earch [N]eovim files" }) end, }, -- To add "add to dictionary" to ltex, but doesn't work... -- { "vigoux/ltex-ls.nvim", dependencies = { "neovim/nvim-lspconfig" } }, { -- LSP Configuration & Plugins "neovim/nvim-lspconfig", dependencies = { -- Automatically install LSPs to stdpath for neovim "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", -- Useful status updates for LSP { "j-hui/fidget.nvim", opts = {} }, -- Lua LSP for Neovim config { "folke/neodev.nvim", opts = {} }, }, config = function() vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), callback = function(event) -- Lua helper function local nmap = function(keys, func, desc) vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) end -- Jump to the definition of the word under your cursor. -- This is where a variable was first declared, or where a function is defined, etc. -- To jump back, press . nmap("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") -- Find references for the word under your cursor. nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") -- Jump to the implementation of the word under your cursor. -- Useful when your language has ways of declaring types without an actual implementation. nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") -- Jump to the type of the word under your cursor. -- Useful when you're not sure what type a variable is and you want to see -- the definition of its *type*, not where it was *defined*. nmap("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") -- Fuzzy find all the symbols in your current workspace -- Similar to document symbols, except searches over your whole project. nmap("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") -- Rename the variable under your cursor -- Most Language Servers support renaming across files, etc. nmap("rn", vim.lsp.buf.rename, "[R]e[n]ame") -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap nmap("K", vim.lsp.buf.hover, "Hover Documentation") -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") -- Highlight references of word under cursor -- local client = vim.lsp.get_client_by_id(event.data.client_id) -- if client and client.server_capabilities.documentHighlightProvider then -- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { -- buffer = event.buf, -- callback = vim.lsp.buf.document_highlight, -- }) -- -- vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { -- buffer = event.buf, -- callback = vim.lsp.buf.clear_references, -- }) -- end end, }) -- Broadcast cmp capabilities to servers. local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) -- Available config keys: -- - cmd (table): Override the default command used to start the server -- - filetypes (table): Override the default list of associated filetypes for the server -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. -- - settings (table): Override the default settings passed when initializing the server. local servers = { lua_ls = { -- cmd = {...}, -- filetypes = { ...}, -- capabilities = {}, settings = { Lua = { completion = { callSnippet = "Replace", }, -- diagnostics = { disable = { 'missing-fields' } }, }, }, }, ltex = { filetypes = { "tex" }, settings = { dictionary = { ["en-US"] = { "homotopy" }, }, }, }, hls = { filetypes = { "haskell", "lhaskell", "cabal" }, haskell = { cabalFormattingProvider = "cabalfmt", formattingProvider = "fourmolu", }, single_file_suppport = true, }, } -- Use :Mason to install manually require("mason").setup() local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { "stylua" }) require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) require("mason-lspconfig").setup({ handlers = { function(server_name) local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for tsserver) server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) require("lspconfig")[server_name].setup(server) end, }, }) end, }, { -- Autoformat "stevearc/conform.nvim", opts = { notify_on_error = false, format_on_save = function(bufnr) -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true, cpp = true } return { timeout_ms = 500, lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], } end, formatters_by_ft = { lua = { "stylua" }, haskell = { "fourmolu" }, json = { "jq" }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- -- You can use a sub-list to tell conform to run *until* a formatter is found. -- javascript = { { "prettierd", "prettier" } }, }, }, }, { -- Autocompletion "hrsh7th/nvim-cmp", event = "InsertEnter", dependencies = { -- Snippet Engine & its associated nvim-cmp source { "L3MON4D3/LuaSnip", -- build needed for regex support build = (function() if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then return end return "make install_jsregexp" end)(), dependencies = { -- { -- -- premade snippets -- "rafamadriz/friendly-snippets", -- config = function() -- require("luasnip.loaders.from_vscode").lazy_load { exclude = { "tex" } } -- require("luasnip.loaders.from_snipmate").lazy_load { exclude = { "tex" } } -- end, -- }, }, config = function() require("luasnip.loaders.from_snipmate").lazy_load() end, }, "saadparwaiz1/cmp_luasnip", -- Adds LSP completion capabilities "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-path", }, config = function() local cmp = require("cmp") local luasnip = require("luasnip") luasnip.config.setup({ enable_autosnippets = true }) cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, -- old one: completeopt = "menuone,noselect", completion = { completeopt = "menu,menuone,noinsert" }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.scroll_docs(-8), [""] = cmp.mapping.scroll_docs(8), -- Accept ([y]es) the completion [""] = cmp.mapping.confirm({ select = true }), -- Manually trigger a completion from nvim-cmp (normally not needed) [""] = cmp.mapping.complete({}), [""] = cmp.mapping(function() if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end end, { "i", "s" }), [""] = cmp.mapping(function() if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end end, { "i", "s" }), }), sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" }, { name = "neorg" }, { name = "orgmode" }, }, }) end, }, { "nvim-lualine/lualine.nvim", dependencies = { { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, }, opts = { options = { icons_enabled = false, theme = "catppuccin", component_separators = "|", section_separators = "", }, -- lualine layout: -- +-------------------------------------------------+ -- | A | B | C X | Y | Z | -- +-------------------------------------------------+ sections = { lualine_x = {}, }, }, }, -- { -- -- Add indentation guides even on blank lines -- "lukas-reineke/indent-blankline.nvim", -- main = "ibl", -- opts = { -- -- char = "┊", -- -- show_trailing_blankline_indent = false, -- }, -- }, -- Highlight todo, notes, etc in comments { "folke/todo-comments.nvim", event = "VimEnter", dependencies = { "nvim-lua/plenary.nvim" }, opts = { signs = false }, }, { -- Collection of various small independent plugins/modules "echasnovski/mini.nvim", config = function() -- Better Around/Inside textobjects -- Examples: -- - yinq - [Y]ank [I]nside [N]ext [']quote -- - ci' - [C]hange [I]nside [']quote require("mini.ai").setup({ n_lines = 500 }) -- Add/delete/replace surroundings (brackets, quotes, etc.) -- -- - saiw( - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr(' - [S]urround [R]eplace [)] ['] -- -- nvim-surround is better... -- require("mini.surround").setup {} -- See 'https://github.com/echasnovski/mini.nvim' for more uses end, }, { -- Highlight, edit, and navigate code "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", dependencies = { -- Interact with treesitter textobjects "nvim-treesitter/nvim-treesitter-textobjects", -- Keeps function description stuck on top "nvim-treesitter/nvim-treesitter-context", -- Extra stuff "nvim-treesitter/nvim-treesitter-refactor", }, opts = { -- Add languages to be installed here that you want installed for treesitter ensure_installed = { "bash", "c", "haskell", "lua", "vim", "vimdoc", -- "org", "norg", "markdown", }, ignore_install = { "latex" }, auto_install = true, -- indent = { enable = true }, highlight = { enable = true, disable = { "latex" }, -- additional_vim_regex_highlighting = { "latex", "markdown" }, }, incremental_selection = { enable = true, keymaps = { -- Defaults -- init_selection = "gnn", -- node_incremental = "grn", -- scope_incremental = "grc", -- node_decremental = "grm", init_selection = "", node_incremental = "", scope_incremental = "", node_decremental = "", }, }, textobjects = { select = { enable = true, -- automatically jump forward to textobj, see targets.vim lookahead = true, keymaps = { -- you can use the capture groups defined in textobjects.scm ["af"] = { query = "@function.outer", desc = "[a]round [f]unction" }, ["if"] = { query = "@function.inner", desc = "[i]nner [f]unction" }, -- [a/i]p is taken for "paragraph". ["aa"] = { query = "@parameter.outer", desc = "[a]round [a]rgument" }, ["ia"] = { query = "@parameter.inner", desc = "[i]nner [a]rgument" }, -- fucks up vimtex commands! -- ['ac'] = '@class.outer', -- ['ic'] = '@class.inner', }, }, move = { enable = true, set_jumps = true, goto_next_start = { ["]m"] = "@function.outer", ["]]"] = "@class.outer", }, goto_next_end = { ["]M"] = "@function.outer", ["]["] = "@class.outer", }, goto_previous_start = { ["[m"] = "@function.outer", ["[["] = "@class.outer", }, goto_previous_end = { ["[M"] = "@function.outer", ["[]"] = "@class.outer", }, }, swap = { enable = true, swap_next = { [">"] = "@parameter.inner", }, swap_previous = { ["<"] = "@parameter.inner", }, }, lsp_interop = { enable = true, border = "none", floating_preview_opts = {}, peek_definition_code = { ["df"] = "@function.outer", ["dF"] = "@class.outer", }, }, }, refactor = { highlight_definitions = { enable = true, -- Set to false if you have an `updatetime` of ~100. clear_on_cursor_move = true, }, highlight_current_scope = { enable = true }, smart_rename = { enable = true, -- Assign keymaps to false to disable them, e.g. `smart_rename = false`. keymaps = { smart_rename = "grr", }, }, }, }, config = function(_, opts) require("nvim-treesitter.configs").setup(opts) end, }, -- Uncomment for debug plugin -- require 'kickstart.plugins.debug', -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins { import = "angryluck.plugins" }, -- { import = "kickstart.plugins" }, }, { ui = { -- Default icons, if no nerd font installed icons = vim.g.have_nerd_font and {} or { cmd = "⌘", config = "🛠", event = "📅", ft = "📂", init = "⚙", keys = "🗝", plugin = "🔌", runtime = "💻", require = "🌙", source = "📄", start = "🚀", task = "📌", lazy = "💤 ", }, }, }) -- require("ltex-ls").setup { -- on_attach = on_attach, -- capabilities = capabilities, -- use_spellfile = false, -- filetypes = { "latex", "tex", "bib", "markdown", "gitcommit", "text" }, -- settings = { -- ltex = { -- enabled = { "latex", "tex", "bib", "markdown" }, -- language = "auto", -- diagnosticSeverity = "information", -- sentenceCacheSize = 2000, -- additionalRules = { -- enablePickyRules = true, -- motherTongue = "fr", -- }, -- disabledRules = { -- fr = { "APOS_TYP", "FRENCH_WHITESPACE" }, -- }, -- dictionary = (function() -- -- For dictionary, search for files in the runtime to have -- -- and include them as externals the format for them is -- -- dict/{LANG}.txt -- -- -- -- Also add dict/default.txt to all of them -- local files = {} -- for _, file in ipairs(vim.api.nvim_get_runtime_file("dict/*", true)) do -- local lang = vim.fn.fnamemodify(file, ":t:r") -- local fullpath = vim.fs.normalize(file, ":p") -- files[lang] = { ":" .. fullpath } -- end -- -- if files.default then -- for lang, _ in pairs(files) do -- if lang ~= "default" then -- vim.list_extend(files[lang], files.default) -- end -- end -- files.default = nil -- end -- return files -- end)(), -- }, -- }, -- } -- modeline -- vim: ts=2 sts=4 sw=2 et