diff --git a/.stylua.toml b/.stylua.toml index 6090f425..3d01d235 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,4 +1,4 @@ -column_width = 120 +column_width = 80 line_endings = "Unix" indent_type = "Spaces" indent_width = 2 diff --git a/init.lua b/init.lua index 456f32f8..604a95ea 100644 --- a/init.lua +++ b/init.lua @@ -16,659 +16,42 @@ if not vim.loop.fs_stat(lazypath) then "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + "--branch=stable", 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 = {}, - }, - }, - }, - +require("lazy").setup( + "angryluck.plugins", + -- For multiple sources: -- { - -- -- Add indentation guides even on blank lines - -- "lukas-reineke/indent-blankline.nvim", - -- main = "ibl", - -- opts = { - -- -- char = "┊", - -- -- show_trailing_blankline_indent = false, - -- }, + -- { import = "angryluck.plugins" }, + -- { import = "kickstart.plugins" }, -- }, - - -- 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", - }, - }, + change_detection = { notify = false }, + 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 = "💤 ", }, }, - - 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 +-- vim: tabstop=2 softtabstop=4 shiftwidth=2 expandtab diff --git a/lua/angryluck/keymaps.lua b/lua/angryluck/keymaps.lua index a221975e..3bc8ad46 100644 --- a/lua/angryluck/keymaps.lua +++ b/lua/angryluck/keymaps.lua @@ -1,3 +1,5 @@ +-- stylua: ignore start + -- [[ Basic Keymaps ]] -- mapleader = " " and maplocalleader = " " are set in init.lua @@ -21,7 +23,7 @@ vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Open diagn vim.keymap.set("t", "", "", { desc = "Exit terminal mode" }) -- Easier window movement (but conflicts with Harpoon) --- vim.keymap.set("n", "", "", { desc = "Move focus to the left window" }) --- vim.keymap.set("n", "", "", { desc = "Move focus to the right window" }) --- vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) --- vim.keymap.set("n", "", "", { desc = "Move focus to the upper window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the left window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the right window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the upper window" }) diff --git a/lua/angryluck/options.lua b/lua/angryluck/options.lua index 72183e1d..e47715af 100644 --- a/lua/angryluck/options.lua +++ b/lua/angryluck/options.lua @@ -50,7 +50,7 @@ vim.opt.splitbelow = true -- wrap between words vim.opt.linebreak = true - +vim.opt.showbreak = "↪ " vim.opt.expandtab = true vim.opt.shiftwidth = 4 vim.opt.tabstop = 8 diff --git a/lua/angryluck/plugins/autocompletion.lua b/lua/angryluck/plugins/autocompletion.lua new file mode 100644 index 00000000..255190a1 --- /dev/null +++ b/lua/angryluck/plugins/autocompletion.lua @@ -0,0 +1,80 @@ +return { + -- 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, +} diff --git a/lua/angryluck/plugins/conform.lua b/lua/angryluck/plugins/conform.lua new file mode 100644 index 00000000..680d1803 --- /dev/null +++ b/lua/angryluck/plugins/conform.lua @@ -0,0 +1,26 @@ +return { -- 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" } }, + }, + }, +} diff --git a/lua/angryluck/plugins/git.lua b/lua/angryluck/plugins/git.lua new file mode 100644 index 00000000..bd5f55d8 --- /dev/null +++ b/lua/angryluck/plugins/git.lua @@ -0,0 +1,17 @@ +return { + -- Git related plugins + "tpope/vim-fugitive", + "tpope/vim-rhubarb", + { + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + }, + }, +} diff --git a/lua/angryluck/plugins/init.lua b/lua/angryluck/plugins/init.lua index bcfee9e7..acb1c745 100644 --- a/lua/angryluck/plugins/init.lua +++ b/lua/angryluck/plugins/init.lua @@ -42,18 +42,15 @@ return { -- "." repeats plugincommands "tpope/vim-repeat", - -- { - -- "ggandor/leap.nvim", - -- -- opts = {}, - -- config = function() - -- require("leap").create_default_mappings() - -- end, - -- }, - { "folke/flash.nvim", event = "VeryLazy", - opts = {}, + opts = { + modes = { + -- enhanced f, F, t, T motions - fix lat8r + char = { enabled = false }, + }, + }, keys = { -- stylua: ignore start { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash", }, @@ -65,8 +62,7 @@ return { }, }, - -- Edit files like nvim buffer - { + { -- Edit files like nvim buffer "stevearc/oil.nvim", opts = {}, -- Optional dependencies @@ -75,4 +71,38 @@ return { require("oil").setup() end, }, + + -- "gc" to comment visual regions/lines + { "numToStr/Comment.nvim", opts = {}, lazy = false }, + + { -- Highlight todo, notes, etc in comments + "folke/todo-comments.nvim", + event = "VimEnter", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { signs = false }, + }, + + -- [ GRAVEYARD ] + -- Plugins I don't use anymore + -------------------------------------------------- + + -- "tpope/vim-sleuth" + + -- { + -- -- Add indentation guides even on blank lines + -- "lukas-reineke/indent-blankline.nvim", + -- main = "ibl", + -- opts = { + -- -- char = "┊", + -- -- show_trailing_blankline_indent = false, + -- }, + -- }, + + -- { + -- "ggandor/leap.nvim", + -- -- opts = {}, + -- config = function() + -- require("leap").create_default_mappings() + -- end, + -- }, } diff --git a/lua/angryluck/plugins/lsp.lua b/lua/angryluck/plugins/lsp.lua new file mode 100644 index 00000000..6dcb95fe --- /dev/null +++ b/lua/angryluck/plugins/lsp.lua @@ -0,0 +1,231 @@ +return { -- 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, + + -- To add "add to dictionary" to ltex, but doesn't work... + -- { "vigoux/ltex-ls.nvim", dependencies = { "neovim/nvim-lspconfig" } }, + + -- Something I tried, but didn't work: + -- 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)(), + -- }, + -- }, + -- } +} diff --git a/lua/angryluck/plugins/lualine.lua b/lua/angryluck/plugins/lualine.lua new file mode 100644 index 00000000..e326e8ae --- /dev/null +++ b/lua/angryluck/plugins/lualine.lua @@ -0,0 +1,19 @@ +return { + "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 = { "filetype" } }, + }, +} diff --git a/lua/angryluck/plugins/mini.lua b/lua/angryluck/plugins/mini.lua new file mode 100644 index 00000000..c1d50f07 --- /dev/null +++ b/lua/angryluck/plugins/mini.lua @@ -0,0 +1,22 @@ +return { -- 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, +} diff --git a/lua/angryluck/plugins/telescope.lua b/lua/angryluck/plugins/telescope.lua new file mode 100644 index 00000000..b5b08af0 --- /dev/null +++ b/lua/angryluck/plugins/telescope.lua @@ -0,0 +1,80 @@ +return { + -- 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") + + -- Mappings + -- See `:help telescope.builtin` + local builtin = require("telescope.builtin") + local nmap = function(key, cmd, desc) + vim.keymap.set("n", key, cmd, { desc = desc }) + end + nmap("sh", builtin.help_tags, "[S]earch [H]elp") + nmap("sk", builtin.keymaps, "[S]earch [K]eymaps") + nmap("sf", builtin.find_files, "[S]earch [F]iles") + nmap("ss", builtin.builtin, "[S]earch [S]elect Telescope") + nmap("sw", builtin.grep_string, "[S]earch current [W]ord") + nmap("sg", builtin.live_grep, "[S]earch by [G]rep") + nmap("sd", builtin.diagnostics, "[S]earch [D]iagnostics") + nmap("sr", builtin.resume, "[S]earch [R]esume") + nmap("s.", builtin.oldfiles, "[S]earch [.] (Recent Files)") + nmap("sg", builtin.git_files, "[S]earch [G]it Files") + nmap("", builtin.buffers, "[ ] Find existing buffers") + nmap("se", ":Telescope emoji", "[S]earch [E]mojis") + + local fuzzy_find = function() + builtin.current_buffer_fuzzy_find( + require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false, + }) + ) + end + nmap("/", fuzzy_find, "[/] Fuzzily search current buffer") + + local live_grep = function() + builtin.live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files", + }) + end + nmap("s/", live_grep, "[S]earch [/] in Open Files") + + local find_files = function() + builtin.find_files({ cwd = vim.fn.stdpath("config") }) + end + nmap("sn", find_files, "[S]earch [N]eovim files") + end, +} diff --git a/lua/angryluck/plugins/treesitter.lua b/lua/angryluck/plugins/treesitter.lua new file mode 100644 index 00000000..f7d9f2d1 --- /dev/null +++ b/lua/angryluck/plugins/treesitter.lua @@ -0,0 +1,129 @@ +return { + -- 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, +} diff --git a/lua/angryluck/plugins/which-key.lua b/lua/angryluck/plugins/which-key.lua new file mode 100644 index 00000000..fdd9027c --- /dev/null +++ b/lua/angryluck/plugins/which-key.lua @@ -0,0 +1,28 @@ +return { -- 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, +}