diff --git a/nvim/.config/nvim/.luarc.json b/nvim.org/.config/nvim/.luarc.json similarity index 100% rename from nvim/.config/nvim/.luarc.json rename to nvim.org/.config/nvim/.luarc.json diff --git a/nvim.org/.config/nvim/init.lua b/nvim.org/.config/nvim/init.lua new file mode 100644 index 0000000..0bb211c --- /dev/null +++ b/nvim.org/.config/nvim/init.lua @@ -0,0 +1,19 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("plugins") +require("vim-options") +require("keymaps") diff --git a/nvim/.config/nvim/lua/keymaps.lua b/nvim.org/.config/nvim/lua/keymaps.lua similarity index 100% rename from nvim/.config/nvim/lua/keymaps.lua rename to nvim.org/.config/nvim/lua/keymaps.lua diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim.org/.config/nvim/lua/plugins.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins.lua rename to nvim.org/.config/nvim/lua/plugins.lua diff --git a/nvim/.config/nvim/lua/plugins/alpha.lua b/nvim.org/.config/nvim/lua/plugins/alpha.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/alpha.lua rename to nvim.org/.config/nvim/lua/plugins/alpha.lua diff --git a/nvim/.config/nvim/lua/plugins/catppucin.lua b/nvim.org/.config/nvim/lua/plugins/catppucin.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/catppucin.lua rename to nvim.org/.config/nvim/lua/plugins/catppucin.lua diff --git a/nvim/.config/nvim/lua/plugins/completions.lua b/nvim.org/.config/nvim/lua/plugins/completions.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/completions.lua rename to nvim.org/.config/nvim/lua/plugins/completions.lua diff --git a/nvim/.config/nvim/lua/plugins/git-stuff.lua b/nvim.org/.config/nvim/lua/plugins/git-stuff.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/git-stuff.lua rename to nvim.org/.config/nvim/lua/plugins/git-stuff.lua diff --git a/nvim/.config/nvim/lua/plugins/lsp-config.lua b/nvim.org/.config/nvim/lua/plugins/lsp-config.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/lsp-config.lua rename to nvim.org/.config/nvim/lua/plugins/lsp-config.lua diff --git a/nvim/.config/nvim/lua/plugins/lualine.lua b/nvim.org/.config/nvim/lua/plugins/lualine.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/lualine.lua rename to nvim.org/.config/nvim/lua/plugins/lualine.lua diff --git a/nvim/.config/nvim/lua/plugins/neorg.lua b/nvim.org/.config/nvim/lua/plugins/neorg.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/neorg.lua rename to nvim.org/.config/nvim/lua/plugins/neorg.lua diff --git a/nvim/.config/nvim/lua/plugins/neotree.lua b/nvim.org/.config/nvim/lua/plugins/neotree.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/neotree.lua rename to nvim.org/.config/nvim/lua/plugins/neotree.lua diff --git a/nvim/.config/nvim/lua/plugins/none-ls.lua b/nvim.org/.config/nvim/lua/plugins/none-ls.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/none-ls.lua rename to nvim.org/.config/nvim/lua/plugins/none-ls.lua diff --git a/nvim/.config/nvim/lua/plugins/nvim-tmux-navigator.lua b/nvim.org/.config/nvim/lua/plugins/nvim-tmux-navigator.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/nvim-tmux-navigator.lua rename to nvim.org/.config/nvim/lua/plugins/nvim-tmux-navigator.lua diff --git a/nvim.org/.config/nvim/lua/plugins/oil.lua b/nvim.org/.config/nvim/lua/plugins/oil.lua new file mode 100644 index 0000000..ab18cde --- /dev/null +++ b/nvim.org/.config/nvim/lua/plugins/oil.lua @@ -0,0 +1,8 @@ +return { + "stevearc/oil.nvim", + config = function() + local oil = require("oil") + oil.setup() + vim.keymap.set("n", "-", oil.toggle_float, {}) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/orgmode.lua.disabled b/nvim.org/.config/nvim/lua/plugins/orgmode.lua.disabled similarity index 100% rename from nvim/.config/nvim/lua/plugins/orgmode.lua.disabled rename to nvim.org/.config/nvim/lua/plugins/orgmode.lua.disabled diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim.org/.config/nvim/lua/plugins/telescope.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/telescope.lua rename to nvim.org/.config/nvim/lua/plugins/telescope.lua diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim.org/.config/nvim/lua/plugins/treesitter.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins/treesitter.lua rename to nvim.org/.config/nvim/lua/plugins/treesitter.lua diff --git a/nvim/.config/nvim/lua/vim-options.lua b/nvim.org/.config/nvim/lua/vim-options.lua similarity index 100% rename from nvim/.config/nvim/lua/vim-options.lua rename to nvim.org/.config/nvim/lua/vim-options.lua diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 0bb211c..55b8979 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,19 +1 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end -end -vim.opt.rtp:prepend(lazypath) - -require("lazy").setup("plugins") -require("vim-options") -require("keymaps") +require("config.lazy") diff --git a/nvim/.config/nvim/lua/config/keymaps.lua b/nvim/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..e4be48e --- /dev/null +++ b/nvim/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,10 @@ +vim.keymap.set("n", "-", "Oil --float", { desc = "Open Parent Directory in Oil" }) +vim.keymap.set("n", "gl", function() + vim.diagnostic.open_float() +end, { desc = "Open Diagnostics in Float" }) + +vim.keymap.set("n", "cf", function() + require("conform").format({ + lsp_format = "fallback", + }) +end, { desc = "Format current file" }) diff --git a/nvim/.config/nvim/lua/config/lazy.lua b/nvim/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..20aa7d7 --- /dev/null +++ b/nvim/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,42 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +require("config.options") + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "kanagawa" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) + +require("config.keymaps") + +-- For video recording purposes +--vim.cmd("ShowkeysToggle") diff --git a/nvim/.config/nvim/lua/config/options.lua b/nvim/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..e3a01d3 --- /dev/null +++ b/nvim/.config/nvim/lua/config/options.lua @@ -0,0 +1,53 @@ +-- Some keyboard mappings as I don't want to break my fingers, while typing on a "german" keyboard ;) +vim.opt.langmap = "+]ü[" +-- Plain langmap remapping does not seem to do the trick :( +vim.keymap.set("n", "ü", "[", { remap = true }) + +vim.opt.expandtab = true -- Convert tabs to spaces +vim.opt.shiftwidth = 4 -- Amount to indent with << and >> +vim.opt.tabstop = 4 -- How many spaces are shown per Tab +vim.opt.softtabstop = 4 -- How many spaces are applied when pressing Tab + +vim.opt.smarttab = true +vim.opt.smartindent = true +vim.opt.autoindent = true -- Keep identation from previous line + +-- Enable break indent +vim.opt.breakindent = true + +-- Always show relative line numbers +vim.opt.number = true +vim.opt.relativenumber = true + +-- Show line under cursor +vim.opt.cursorline = true + +-- Store undos between sessions +vim.opt.undofile = true + +-- Enable mouse mode, can be useful for resizing splits for example! +vim.opt.mouse = "a" + +-- Don't show the mode, since it's already in the status line +vim.opt.showmode = false + +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Keep signcolumn on by default +vim.opt.signcolumn = "yes" + +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +vim.opt.list = true +vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } + +-- Minimal number of screen lines to keep above and below the cursor. +vim.opt.scrolloff = 5 + diff --git a/nvim/.config/nvim/lua/plugins/blink-cmp.lua b/nvim/.config/nvim/lua/plugins/blink-cmp.lua new file mode 100644 index 0000000..c69426d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/blink-cmp.lua @@ -0,0 +1,110 @@ +return { + { + "saghen/blink.compat", + -- use the latest release, via version = '*', if you also use the latest release for blink.cmp + version = "*", + -- lazy.nvim will automatically load the plugin when it's required by blink.cmp + lazy = true, + -- make sure to set opts so that lazy.nvim calls blink.compat's setup + opts = {}, + }, + { + "saghen/blink.cmp", + -- optional: provides snippets for the snippet source + dependencies = { + "rafamadriz/friendly-snippets", + "moyiz/blink-emoji.nvim", + "ray-x/cmp-sql", + }, + + -- use a release tag to download pre-built binaries + version = "1.*", + -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { + preset = "default", + [""] = { "accept", "fallback" }, + }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = true } }, + signature = { enabled = true }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { "lsp", "path", "snippets", "buffer", "emoji", "sql" }, + providers = { + emoji = { + module = "blink-emoji", + name = "Emoji", + score_offset = 15, -- Tune by preference + opts = { insert = true }, -- Insert emoji (default) or complete its name + should_show_items = function() + return vim.tbl_contains( + -- Enable emoji completion only for git commits and markdown. + -- By default, enabled for all file-types. + { "gitcommit", "markdown" }, + vim.o.filetype + ) + end, + }, + sql = { + -- IMPORTANT: use the same name as you would for nvim-cmp + name = "sql", + module = "blink.compat.source", + + -- all blink.cmp source config options work as normal: + score_offset = -3, + + -- this table is passed directly to the proxied completion source + -- as the `option` field in nvim-cmp's source config + -- + -- this is NOT the same as the opts in a plugin's lazy.nvim spec + opts = {}, + should_show_items = function() + return vim.tbl_contains( + -- Enable emoji completion only for git commits and markdown. + -- By default, enabled for all file-types. + { "sql" }, + vim.o.filetype + ) + end, + }, + }, + }, + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" }, + }, + opts_extend = { "sources.default" }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua new file mode 100644 index 0000000..a0107ff --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -0,0 +1,20 @@ +return { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stylua" }, + -- Conform will run multiple formatters sequentially + python = { "isort", "black" }, + -- You can customize some of the format options for the filetype (:help conform.format) + rust = { "rustfmt" }, + -- Conform will run the first available formatter + javascript = { "prettierd", "prettier", stop_after_first = true }, + typescript = { "prettierd", "prettier", stop_after_first = true }, + }, + format_on_save = { + -- These options will be passed to conform.format() + timeout_ms = 500, + lsp_format = "fallback", + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/dressing.lua b/nvim/.config/nvim/lua/plugins/dressing.lua new file mode 100644 index 0000000..65d7987 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/dressing.lua @@ -0,0 +1,4 @@ +return { + 'stevearc/dressing.nvim', + opts = {}, +} diff --git a/nvim/.config/nvim/lua/plugins/fzflua.lua b/nvim/.config/nvim/lua/plugins/fzflua.lua new file mode 100644 index 0000000..240bf26 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/fzflua.lua @@ -0,0 +1,95 @@ +return { + "ibhagwan/fzf-lua", + -- optional for icon support + -- dependencies = { "nvim-tree/nvim-web-devicons" }, + -- or if using mini.icons/mini.nvim + dependencies = { "echasnovski/mini.icons" }, + opts = {}, + keys={ + { + "ff", + function() require('fzf-lua').files() end, + desc="Find Files in project directory" + }, + { + "fg", + function() require('fzf-lua').live_grep() end, + desc="Find by grepping in project directory" + }, + { + "fc", + function() require('fzf-lua').files({cwd=vim.fn.stdpath("config")}) end, + desc="Find in neovim configuration" + }, + { + "fh", + function() + require("fzf-lua").helptags() + end, + desc = "[F]ind [H]elp", + }, + { + "fk", + function() + require("fzf-lua").keymaps() + end, + desc = "[F]ind [K]eymaps", + }, + { + "fb", + function() + require("fzf-lua").builtin() + end, + desc = "[F]ind [B]uiltin FZF", + }, + { + "fw", + function() + require("fzf-lua").grep_cword() + end, + desc = "[F]ind current [W]ord", + }, + { + "fW", + function() + require("fzf-lua").grep_cWORD() + end, + desc = "[F]ind current [W]ORD", + }, + { + "fd", + function() + require("fzf-lua").diagnostics_document() + end, + desc = "[F]ind [D]iagnostics", + }, + { + "fr", + function() + require("fzf-lua").resume() + end, + desc = "[F]ind [R]esume", + }, + { + "fo", + function() + require("fzf-lua").oldfiles() + end, + desc = "[F]ind [O]ld Files", + }, + { + "", + function() + require("fzf-lua").buffers() + end, + desc = "[,] Find existing buffers", + }, + { + "/", + function() + require("fzf-lua").lgrep_curbuf() + end, + desc = "[/] Live grep the current buffer", + }, + } +} diff --git a/nvim/.config/nvim/lua/plugins/kanagawa.lua b/nvim/.config/nvim/lua/plugins/kanagawa.lua new file mode 100644 index 0000000..29e302b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/kanagawa.lua @@ -0,0 +1,21 @@ +return { + "rebelot/kanagawa.nvim", + branch="master", + config=function() + require('kanagawa').setup({ + transparent=true, + overrides=function(colors) + return { + ["@markup.link.url.markdown_inline"] = { link = "Special" }, -- (url) + ["@markup.link.label.markdown_inline"] = { link = "WarningMsg" }, -- [label] + ["@markup.italic.markdown_inline"] = { link = "Exception" }, -- *italic* + ["@markup.raw.markdown_inline"] = { link = "String" }, -- `code` + ["@markup.list.markdown"] = { link = "Function" }, -- + list + ["@markup.quote.markdown"] = { link = "Error" }, -- > blockcode + ["@markup.list.checked.markdown"] = { link = "WarningMsg" } -- - [X] checked list item + } + end + }); + vim.cmd("colorscheme kanagawa"); + end, +} diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..f436e87 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,272 @@ +return { + -- Main LSP Configuration + "neovim/nvim-lspconfig", + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + -- Mason must be loaded before its dependents so we need to set it up here. + -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` + { "williamboman/mason.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + + -- Useful status updates for LSP. + { "j-hui/fidget.nvim", opts = {} }, + }, + config = function() + -- Brief aside: **What is LSP?** + -- + -- LSP is an initialism you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + callback = function(event) + -- NOTE: Remember that Lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or "n" + vim.keymap.set(mode, 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 . + map("gd", require("fzf-lua").lsp_definitions, "[G]oto [D]efinition") + + -- Find references for the word under your cursor. + map("gr", require("fzf-lua").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. + map("gI", require("fzf-lua").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*. + map("D", require("fzf-lua").lsp_typedefs, "Type [D]efinition") + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map("ds", require("fzf-lua").lsp_document_symbols, "[D]ocument [S]ymbols") + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map("ws", require("fzf-lua").lsp_live_workspace_symbols, "[W]orkspace [S]ymbols") + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map("cr", 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. + map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + + -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) + ---@param client vim.lsp.Client + ---@param method vim.lsp.protocol.Method + ---@param bufnr? integer some lsp support methods only in specific files + ---@return boolean + local function client_supports_method(client, method, bufnr) + if vim.fn.has("nvim-0.11") == 1 then + return client:supports_method(method, bufnr) + else + return client.supports_method(method, { bufnr = bufnr }) + end + end + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if + client + and client_supports_method( + client, + vim.lsp.protocol.Methods.textDocument_documentHighlight, + event.buf + ) + then + local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd("LspDetach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) + end, + }) + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if + client + and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) + then + map("th", function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) + end, "[T]oggle Inlay [H]ints") + end + end, + }) + + -- Diagnostic Config + -- See :help vim.diagnostic.Opts + vim.diagnostic.config({ + severity_sort = true, + float = { border = "rounded", source = "if_many" }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "󰅚 ", + [vim.diagnostic.severity.WARN] = "󰀪 ", + [vim.diagnostic.severity.INFO] = "󰋽 ", + [vim.diagnostic.severity.HINT] = "󰌶 ", + }, + }, + virtual_text = { + source = "if_many", + spacing = 2, + format = function(diagnostic) + local diagnostic_message = { + [vim.diagnostic.severity.ERROR] = diagnostic.message, + [vim.diagnostic.severity.WARN] = diagnostic.message, + [vim.diagnostic.severity.INFO] = diagnostic.message, + [vim.diagnostic.severity.HINT] = diagnostic.message, + } + return diagnostic_message[diagnostic.severity] + end, + }, + }) + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local original_capabilities = vim.lsp.protocol.make_client_capabilities() + local capabilities = require("blink.cmp").get_lsp_capabilities(original_capabilities) + -- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - 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. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + bashls = {}, + marksman = {}, + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`ts_ls`) will work just fine + -- ts_ls = {}, + -- + + lua_ls = { + -- cmd = { ... }, + -- filetypes = { ... }, + -- capabilities = {}, + -- settings = { + -- Lua = { + -- completion = { + -- callSnippet = 'Replace', + -- }, + -- -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- -- diagnostics = { disable = { 'missing-fields' } }, + -- }, + -- }, + }, + } + + -- Ensure the servers and tools above are installed + -- + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + -- + -- `mason` had to be setup earlier: to configure its options see the + -- `dependencies` table for `nvim-lspconfig` above. + -- + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + "stylua", -- Used to format Lua code + "prettierd", -- Used to format javascript and typescript code + }) + require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + + require("mason-lspconfig").setup({ + ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + automatic_installation = false, + 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 ts_ls) + server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/nvim-treesitter-textobjects.lua b/nvim/.config/nvim/lua/plugins/nvim-treesitter-textobjects.lua new file mode 100644 index 0000000..40c9ec1 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/nvim-treesitter-textobjects.lua @@ -0,0 +1,63 @@ +return { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = { + "nvim-treesitter/nvim-treesitter" + }, + init = function() + local config = require'nvim-treesitter.configs'; + config.setup({ + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ao"] = "@comment.outer", + -- You can optionally set descriptions to the mappings (used in the desc parameter of + -- nvim_buf_set_keymap) which plugins like which-key display + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" }, + -- You can also use captures from other query groups like `locals.scm` + ["as"] = { query = "@local.scope", query_group = "locals", desc = "Select language scope" }, + }, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '') or a table + -- mapping query_strings to modes. + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- blockwise + }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true or false + include_surrounding_whitespace = true, + }, + swap = { + enable = true, + swap_next = { + ["a"] = {query="@parameter.inner", desc="Swap with next parameter"}, + }, + swap_previous = { + ["A"] = "@parameter.inner", + }, + }, + }, + }); + end +} diff --git a/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua b/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..1c9c6a2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,27 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function () + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { + "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html", "markdown", "markdown_inline" + }, + auto_install = true, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", -- set to `false` to disable one of the mappings + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end +} diff --git a/nvim/.config/nvim/lua/plugins/oil.lua b/nvim/.config/nvim/lua/plugins/oil.lua index ab18cde..19f7ed9 100644 --- a/nvim/.config/nvim/lua/plugins/oil.lua +++ b/nvim/.config/nvim/lua/plugins/oil.lua @@ -1,8 +1,15 @@ return { - "stevearc/oil.nvim", - config = function() - local oil = require("oil") - oil.setup() - vim.keymap.set("n", "-", oil.toggle_float, {}) - end, + "stevearc/oil.nvim", + ---@module 'oil' + ---@type oil.SetupOpts + opts = { + view_options = { + show_hidden = true, + }, + }, + -- Optional dependencies + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, } diff --git a/nvim/.config/nvim/lua/plugins/project.lua b/nvim/.config/nvim/lua/plugins/project.lua new file mode 100644 index 0000000..143b66d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/project.lua @@ -0,0 +1,40 @@ +return { + "ahmedkhalf/project.nvim", + init = function() + require("project_nvim").setup { + -- your configuration comes her + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + + + -- Absolutely minimal implementation of fzf-lua based project finder + -- for fzf-lua, due to request from @KrisWilliams1 (Maybe extended to a + -- full blown port from the original selector in the future) + local history = require("project_nvim.utils.history") + local project = require("project_nvim.project") + + vim.api.nvim_create_user_command("FzfProjects", function() + local projects = history.get_recent_projects() + + require("fzf-lua").fzf_exec(projects, { + prompt = "Projects> ", + actions = { + ["default"] = function(selected) + if selected and #selected > 0 then + local project_path = selected[1] + if project.set_pwd(project_path, "fzf-lua") then + require("fzf-lua").files() + end + end + end + } + }) + end, {}) + end, + keys = { + { + "fp", "FzfProjects", desc="Find Recent Projects" + } + } +} diff --git a/nvim/.config/nvim/lua/plugins/rustacean.lua b/nvim/.config/nvim/lua/plugins/rustacean.lua new file mode 100644 index 0000000..46c4c82 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/rustacean.lua @@ -0,0 +1,5 @@ +return { + 'mrcjkb/rustaceanvim', + version = '^5', -- Recommended + lazy = false, -- This plugin is already lazy +} diff --git a/nvim/.config/nvim/lua/plugins/showkeys.lua b/nvim/.config/nvim/lua/plugins/showkeys.lua new file mode 100644 index 0000000..fc6ec18 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/showkeys.lua @@ -0,0 +1,7 @@ +return { + "nvzone/showkeys", + cmd = "ShowkeysToggle", + opts={ + maxkeys=5 + } +} diff --git a/nvim/.config/nvim/lua/plugins/sleuth-vim.lua b/nvim/.config/nvim/lua/plugins/sleuth-vim.lua new file mode 100644 index 0000000..d04ea94 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/sleuth-vim.lua @@ -0,0 +1,5 @@ +return { + "tpope/vim-sleuth", + -- No further initialization needed, as this is a real "vim" not a lua + -- plugin. +} diff --git a/nvim/.config/nvim/lua/plugins/statusline.lua b/nvim/.config/nvim/lua/plugins/statusline.lua new file mode 100644 index 0000000..4a51017 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/statusline.lua @@ -0,0 +1 @@ +return { 'echasnovski/mini.statusline', version = false, opts={} } diff --git a/nvim/.config/nvim/lua/plugins/which-key.lua b/nvim/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..9fadb97 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,18 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +}