From 7d759edf68303c7681a6521fbc3675661204cd4f Mon Sep 17 00:00:00 2001 From: Ibrahim Muftee Date: Tue, 24 Jun 2025 11:26:15 -0500 Subject: feat(nvim): replace old config with new one --- dot_config/nvim/init.lua | 2 +- dot_config/nvim/lazy-lock.json | 35 +- dot_config/nvim/lua/config/lazy.lua | 36 -- dot_config/nvim/lua/ibrahim/init.lua | 19 ++ dot_config/nvim/lua/ibrahim/keymaps.lua | 167 +++++++++ dot_config/nvim/lua/ibrahim/lazy_init.lua | 34 ++ dot_config/nvim/lua/ibrahim/options.lua | 35 ++ .../nvim/lua/ibrahim/plugins/actions-preview.lua | 6 + .../nvim/lua/ibrahim/plugins/colorscheme.lua | 2 + dot_config/nvim/lua/ibrahim/plugins/commenter.lua | 11 + dot_config/nvim/lua/ibrahim/plugins/conform.lua | 48 +++ dot_config/nvim/lua/ibrahim/plugins/dap.lua | 94 +++++ dot_config/nvim/lua/ibrahim/plugins/fugitive.lua | 6 + dot_config/nvim/lua/ibrahim/plugins/gitsigns.lua | 20 ++ dot_config/nvim/lua/ibrahim/plugins/gruvbox.lua | 1 + dot_config/nvim/lua/ibrahim/plugins/harpoon.lua | 30 ++ dot_config/nvim/lua/ibrahim/plugins/jinja.lua | 3 + dot_config/nvim/lua/ibrahim/plugins/lsp-lines.lua | 35 ++ dot_config/nvim/lua/ibrahim/plugins/lsp.lua | 377 +++++++++++++++++++++ dot_config/nvim/lua/ibrahim/plugins/mini.lua | 8 + dot_config/nvim/lua/ibrahim/plugins/neotest.lua | 44 +++ dot_config/nvim/lua/ibrahim/plugins/nvim-cmp.lua | 119 +++++++ .../nvim/lua/ibrahim/plugins/nvim-colorizer.lua | 6 + .../nvim/lua/ibrahim/plugins/obsidian.lua.tmpl | 82 +++++ dot_config/nvim/lua/ibrahim/plugins/oil.lua | 15 + dot_config/nvim/lua/ibrahim/plugins/telescope.lua | 12 + .../nvim/lua/ibrahim/plugins/todo-comments.lua | 6 + dot_config/nvim/lua/ibrahim/plugins/treesitter.lua | 132 ++++++++ dot_config/nvim/lua/ibrahim/plugins/undotree.lua | 8 + dot_config/nvim/lua/ibrahim/plugins/which-key.lua | 4 + dot_config/nvim/lua/plugins/colorscheme.lua | 2 - dot_config/nvim/lua/plugins/gitsigns.lua | 20 -- dot_config/nvim/lua/plugins/gruvbox.lua | 1 - dot_config/nvim/lua/plugins/harpoon.lua | 30 -- dot_config/nvim/lua/plugins/jinja.lua | 3 - dot_config/nvim/lua/plugins/lsp-lines.lua | 35 -- dot_config/nvim/lua/plugins/lsp.lua | 334 ------------------ dot_config/nvim/lua/plugins/neotest.lua | 44 --- dot_config/nvim/lua/plugins/obsidian.lua.tmpl | 82 ----- dot_config/nvim/lua/plugins/oil.lua | 15 - dot_config/nvim/lua/plugins/telescope.lua | 12 - dot_config/nvim/lua/plugins/todo-comments.lua | 6 - dot_config/nvim/lua/plugins/treesitter.lua | 132 -------- dot_config/nvim/lua/plugins/undotree.lua | 8 - dot_config/nvim/lua/plugins/which-key.lua | 4 - dot_config/nvim/plugin/keymaps.lua | 165 --------- dot_config/nvim/plugin/options.lua | 35 -- 47 files changed, 1345 insertions(+), 980 deletions(-) delete mode 100644 dot_config/nvim/lua/config/lazy.lua create mode 100644 dot_config/nvim/lua/ibrahim/init.lua create mode 100644 dot_config/nvim/lua/ibrahim/keymaps.lua create mode 100644 dot_config/nvim/lua/ibrahim/lazy_init.lua create mode 100644 dot_config/nvim/lua/ibrahim/options.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/actions-preview.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/colorscheme.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/commenter.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/conform.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/dap.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/fugitive.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/gitsigns.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/gruvbox.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/harpoon.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/jinja.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/lsp-lines.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/lsp.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/mini.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/neotest.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/nvim-cmp.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/nvim-colorizer.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/obsidian.lua.tmpl create mode 100644 dot_config/nvim/lua/ibrahim/plugins/oil.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/telescope.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/todo-comments.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/treesitter.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/undotree.lua create mode 100644 dot_config/nvim/lua/ibrahim/plugins/which-key.lua delete mode 100644 dot_config/nvim/lua/plugins/colorscheme.lua delete mode 100644 dot_config/nvim/lua/plugins/gitsigns.lua delete mode 100644 dot_config/nvim/lua/plugins/gruvbox.lua delete mode 100644 dot_config/nvim/lua/plugins/harpoon.lua delete mode 100644 dot_config/nvim/lua/plugins/jinja.lua delete mode 100644 dot_config/nvim/lua/plugins/lsp-lines.lua delete mode 100644 dot_config/nvim/lua/plugins/lsp.lua delete mode 100644 dot_config/nvim/lua/plugins/neotest.lua delete mode 100644 dot_config/nvim/lua/plugins/obsidian.lua.tmpl delete mode 100644 dot_config/nvim/lua/plugins/oil.lua delete mode 100644 dot_config/nvim/lua/plugins/telescope.lua delete mode 100644 dot_config/nvim/lua/plugins/todo-comments.lua delete mode 100644 dot_config/nvim/lua/plugins/treesitter.lua delete mode 100644 dot_config/nvim/lua/plugins/undotree.lua delete mode 100644 dot_config/nvim/lua/plugins/which-key.lua delete mode 100644 dot_config/nvim/plugin/keymaps.lua delete mode 100644 dot_config/nvim/plugin/options.lua (limited to 'dot_config/nvim') diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index 55b8979..32dd0ba 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -1 +1 @@ -require("config.lazy") +require("ibrahim") diff --git a/dot_config/nvim/lazy-lock.json b/dot_config/nvim/lazy-lock.json index 77d8449..3c70415 100644 --- a/dot_config/nvim/lazy-lock.json +++ b/dot_config/nvim/lazy-lock.json @@ -1,41 +1,46 @@ { "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" }, + "LuaSnip": { "branch": "master", "commit": "c1851d5c519611dfc451b6582961b2602e0af89b" }, "actions-preview.nvim": { "branch": "master", "commit": "36513ad213855d497b7dd3391a24d1d75d58e36f" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, - "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, + "conform.nvim": { "branch": "master", "commit": "a4bb5d6c4ae6f32ab13114e62e70669fa67745b9" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" }, "gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lsp-zero.nvim": { "branch": "v4.x", "commit": "d502a22640d0ff4752547c6d71f117a1bb2bb653" }, "lsp_lines.nvim": { "branch": "main", "commit": "a92c755f182b89ea91bd8a6a2227208026f27b4d" }, "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, - "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, - "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, - "neotest-python": { "branch": "master", "commit": "ed9b4d794b89044cc32e5476e637936331473c6e" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ce0e87c0be12e7c48296a7513e90430e3eac7f24" }, + "mason.nvim": { "branch": "main", "commit": "9eaedb864cdadc29c6eb7d761a6c0d8aee26c91b" }, + "mini.nvim": { "branch": "main", "commit": "94cae4660a8b2d95dbbd56e1fbc6fcfa2716d152" }, + "neotest": { "branch": "master", "commit": "862afb2a2219d9ca565f67416fb7003cc0f22c4f" }, + "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "5e0e9c00d51fcb7efef0d4c49023f9593b38661e" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, + "nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" }, + "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, + "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, + "nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "89ebe73cd2836db80a22d9748999ace0241917a5" }, - "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, + "nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "a91cd95f50bf991106403cb02c5851b92e45820e" }, + "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "oil.nvim": { "branch": "master", "commit": "08c2bce8b00fd780fb7999dbffdf7cd174e896fb" }, + "oil.nvim": { "branch": "master", "commit": "685cdb4ffa74473d75a1b97451f8654ceeab0f4a" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rose-pine": { "branch": "main", "commit": "6b9840790cc7acdfadde07f308d34b62dd9cc675" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" }, + "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" }, "vim-jinja": { "branch": "master", "commit": "7c54e2320c5f676636cdd8697480782eebfb2bf2" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/dot_config/nvim/lua/config/lazy.lua b/dot_config/nvim/lua/config/lazy.lua deleted file mode 100644 index 2e0f130..0000000 --- a/dot_config/nvim/lua/config/lazy.lua +++ /dev/null @@ -1,36 +0,0 @@ --- 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 = " " - --- Setup lazy.nvim -require("lazy").setup({ - spec = { - -- import your plugins - { import = "plugins" }, - }, - -- Configure any other settings here. See the documentation for more details. - -- automatically check for plugin updates - checker = { enabled = true }, - change_detection = { - notify = false, - } -}) diff --git a/dot_config/nvim/lua/ibrahim/init.lua b/dot_config/nvim/lua/ibrahim/init.lua new file mode 100644 index 0000000..99a97be --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/init.lua @@ -0,0 +1,19 @@ +require("ibrahim.lazy_init") +require("ibrahim.options") +require("ibrahim.keymaps") + +-- Format automatically after writing file +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + + if client ~= nil and client:supports_method('textDocument/formatting') then + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({bufnr = args.buf, id = client.id}) + end, + }) + end + end, +}) diff --git a/dot_config/nvim/lua/ibrahim/keymaps.lua b/dot_config/nvim/lua/ibrahim/keymaps.lua new file mode 100644 index 0000000..feb84da --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/keymaps.lua @@ -0,0 +1,167 @@ +-- Set leader key as Space +vim.g.mapleader = " " + +local function map(mode, left, right, opts) + local default_opts = { + noremap = true, + silent = true, + } + opts = opts or {} + -- "keep" mode preserves the values from the leftmost table, + -- so prioritize any options provided over the defaults + local full_opts = vim.tbl_extend("keep", opts, default_opts) + vim.keymap.set(mode, left, right, full_opts) +end + +-- Clear any highlighted searches when pressing Esc +-- This lets me leave hlsearch on by default while having an easy way to clear +-- it again. +map({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) + +-- Move lines while in visual mode with J and K +map("v", "J", ":m '>+1gv=gv") +map("v", "K", ":m '<-2gv=gv") + +-- Easier execution of Lua code +map("n", "x", ".lua", { desc = "Execute the current line" }) +map("n", "x", "source %", { desc = "Execute the current file" }) + +-- Keep cursor in the same place when using J to join lines +map("n", "J", "mzJ`z") + +-- Center the screen when jumping around with C-d and C-u +map("n", "", "zz") +map("n", "", "zz") + +-- Center the screen when jumping to next / previous search terms +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- Quick maps to paste/delete without overwriting the current buffer +map("x", "p", '"_dP') +map({ "n", "v" }, "d", '"_dP') + +-- Easier quickfix naviagion +map("n", "", "cprev", { desc = "Quickfix previous item" }) +map("n", "", "cnext", { desc = "Quickfix next item" }) + +-- System clipboard +map({ "n", "v" }, "cd", '"+d', { desc = "Clipboard delete" }) +map({ "n", "v" }, "cp", '"+p', { desc = "Clipboard paste" }) +map({ "n", "v" }, "cy", '"+y', { desc = "Clipboard yank" }) + +-- Map g- to netrw (temporary placeholder for oil) +-- map("n", "g-", vim.cmd.Ex, { desc = "Open netrw" }) + +map("n", "gx", function() + local command = "go run " .. vim.fn.expand("%") + local f = assert(io.popen(command, "r")) + local s = assert(f:read("*a")) + f:close() + s = string.gsub(s, "^%s+", "") + s = string.gsub(s, "%s+$", "") + s = string.gsub(s, "[\n\r]+", " ") + print(s) +end, { desc = "Execute current go file" }) + + +-- Create a GitHub URL for the current file and line number, and copy it +-- to the clipboard. +map("n", "yfg", function() + local remote_url = vim.fn.system("git config --get remote.origin.url") + if not remote_url:find("github.com") then + vim.notify("This is not a GitHub repository") + return + end + + local trimmed_remote_url = remote_url:gsub("%.git", ""):gsub("%s+", ""):gsub("\n", "") + local branch_name = vim.fn.system("git rev-parse --abbrev-ref HEAD"):gsub("\n", "") + + -- Now construct the link in this format: + -- /blob//#L + + local filepath = vim.fn.expand("%:."):gsub("\\", "/") + + local line = vim.fn.line(".") + local result = trimmed_remote_url .. "/blob/" .. branch_name .. "/" .. filepath .. "#L" .. line + + vim.fn.setreg("+", result) + vim.notify("Copied GitHub URL to clipboard: " .. result) +end, { desc = "Yank GitHub URL to clipboard", expr = true }) + + +-- LSP specific keybindings +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("IbrahimLspConfig", {}), + callback = function(evt) + local function lsp_map(mode, lhs, rhs, desc) + local opts = { buffer = evt.buf, desc = "LSP: " .. (desc or "") } + map(mode, lhs, rhs, opts) + end + + local has_telescope, _ = pcall(require, "telescope") + local function lsp_telescope_map(mode, lhs, with_telescope_rhs, no_telescope_rhs, desc) + if has_telescope then + desc = desc .. " (Telescope)" + lsp_map(mode, lhs, with_telescope_rhs, desc) + else + lsp_map(mode, lhs, no_telescope_rhs, desc) + end + end + local function tele_builtin(name, opts) + return function() + require("telescope.builtin")[name](opts) + end + end + + -- Navigation + lsp_map("n", "gd", vim.lsp.buf.definition, "[G]oto [D]efinition") + lsp_map("n", "gt", vim.lsp.buf.type_definition, "[G]oto [t]ype Definition") + lsp_map("n", "gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + lsp_map("n", "gr", vim.lsp.buf.references, "[G]oto [R]eferences") + lsp_map("n", "gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation") + + lsp_telescope_map("n", "gr", tele_builtin("lsp_references"), vim.lsp.buf.references, "Go to references") + lsp_telescope_map( + "n", + "sn", + tele_builtin("lsp_document_symbols"), + vim.lsp.buf.document_symbol, + "Search document symbols" + ) + lsp_telescope_map( + "n", + "sN", + tele_builtin("lsp_dynamic_workspace_symbols"), + vim.lsp.buf.workspace_symbol, + "Search workspace symbols" + ) + + -- Code changes + lsp_map("n", "cr", vim.lsp.buf.rename, "Rename") + -- ca is being overwritten by the 'actions-preview' plugin + -- lsp_map("n", "ca", vim.lsp.buf.code_action, "Code actions") + + -- Diagnostics + lsp_map("n", "ds", vim.diagnostic.open_float, "[s]how [d]iagnostic window") + lsp_map("n", "dn", function() + vim.diagnostic.jump({ count = 1, float = true }) + end, "Go to [n]ext [d]iagnostic") + lsp_map("n", "dp", function() + vim.diagnostic.jump({ count = -1, float = true }) + end, "Go to [p]revious [d]iagnostic") + + -- See `:help K` for why this keymap + lsp_map("n", "K", function () + vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 } + end, "Hover Documentation") + lsp_map("n", "", vim.lsp.buf.signature_help, "Signature Documentation") + + -- Workspace + lsp_map("n", "wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") + lsp_map("n", "wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + lsp_map("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, "[W]orkspace [L]ist Folders") + end, +}) diff --git a/dot_config/nvim/lua/ibrahim/lazy_init.lua b/dot_config/nvim/lua/ibrahim/lazy_init.lua new file mode 100644 index 0000000..4d88957 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/lazy_init.lua @@ -0,0 +1,34 @@ +-- 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) + +vim.g.mapleader = " " +vim.opt.termguicolors = true + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "ibrahim.plugins" }, + }, + install = { colorscheme = { "rose-pine" } }, + -- Configure any other settings here. See the documentation for more details. + -- automatically check for plugin updates + checker = { enabled = true }, + change_detection = { + notify = false, + } +}) diff --git a/dot_config/nvim/lua/ibrahim/options.lua b/dot_config/nvim/lua/ibrahim/options.lua new file mode 100644 index 0000000..9e7252b --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/options.lua @@ -0,0 +1,35 @@ +local opt = vim.opt + +opt.incsearch = true + +opt.number = true +opt.relativenumber = true + +opt.scrolloff = 8 + +vim.o.foldtext = "" +opt.foldlevelstart = 1 + +opt.conceallevel = 2 + +opt.tabstop = 4 +opt.softtabstop = 4 +opt.shiftwidth = 0 +opt.expandtab = true + +opt.autoindent = true +opt.smartindent = true +opt.breakindent = true + +opt.swapfile = false +opt.backup = false +opt.undodir = vim.fn.expand("~/.vim/undodir") +opt.undofile = true + +opt.ignorecase = true +opt.smartcase = true + +opt.updatetime = 250 + +vim.o.background = "dark" +vim.cmd([[colorscheme rose-pine]]) diff --git a/dot_config/nvim/lua/ibrahim/plugins/actions-preview.lua b/dot_config/nvim/lua/ibrahim/plugins/actions-preview.lua new file mode 100644 index 0000000..05532c4 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/actions-preview.lua @@ -0,0 +1,6 @@ +return { + "aznhe21/actions-preview.nvim", + config = function() + vim.keymap.set({ "v", "n" }, "ca", require("actions-preview").code_actions) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/colorscheme.lua b/dot_config/nvim/lua/ibrahim/plugins/colorscheme.lua new file mode 100644 index 0000000..7cc5fd9 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/colorscheme.lua @@ -0,0 +1,2 @@ +-- return { "ellisonleao/gruvbox.nvim", priority = 1000, config = true } +return { "rose-pine/neovim", name = "rose-pine", priority = 1000, config = true } diff --git a/dot_config/nvim/lua/ibrahim/plugins/commenter.lua b/dot_config/nvim/lua/ibrahim/plugins/commenter.lua new file mode 100644 index 0000000..cdc88fe --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/commenter.lua @@ -0,0 +1,11 @@ +return { + 'echasnovski/mini.nvim', + version = false, + config = function(_, opts) + -- I'm not sure why this is requireed. I thought Lazy.nvim didn't require the + -- config key if the only line in the function was to call setup(). + -- However, without this key, this plugin fails to load with the error + -- "mini" could not be found + require("mini.comment").setup(opts) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/conform.lua b/dot_config/nvim/lua/ibrahim/plugins/conform.lua new file mode 100644 index 0000000..c1b38ab --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/conform.lua @@ -0,0 +1,48 @@ +-- Use prettierd if it's available or prettier otherwise, but don't +-- try to run them both. +local prettier = { { "prettierd", "prettier" } } + +return { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + cmd = { "ConformInfo", "Format" }, + opts = { + formatters = { + sqlfluff = { + -- By default, SQLFluff uses "ansi" formatting. My projects + -- right now use MySQL formatting instead. + -- Still looking for a better way to manage this. + args = { "fix", "--force", "--dialect=mysql", "-" }, + }, + }, + formatters_by_ft = { + lua = { "stylua" }, + + -- Ruff LSP handles formatting for Python code + -- -- Multiple items in one table will be run sequentially + python = { "ruff_format" }, + + c = { "clang-format" }, + css = prettier, + html = prettier, + javascript = prettier, + json = prettier, + markdown = prettier, + typescript = prettier, + yaml = prettier, + + sql = { "sqlfluff" }, + }, + }, + config = function(_, opts) + local conform = require("conform") + require("conform").setup(opts) + + local function format() + conform.format({ async = true, lsp_fallback = true }) + end + + vim.keymap.set({ "n", "v" }, "rf", format, { desc = "Reformat" }) + vim.api.nvim_create_user_command("Format", format, {}) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/dap.lua b/dot_config/nvim/lua/ibrahim/plugins/dap.lua new file mode 100644 index 0000000..4e1df62 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/dap.lua @@ -0,0 +1,94 @@ +return { + { + "mfussenegger/nvim-dap", + dependencies = { + "leoluz/nvim-dap-go", + "rcarriga/nvim-dap-ui", + "theHamsta/nvim-dap-virtual-text", + "nvim-neotest/nvim-nio", + "williamboman/mason.nvim", + }, + config = function() + local dap = require "dap" + local ui = require "dapui" + + require("dapui").setup() + -- require("dap-go").setup() + + -- require("nvim-dap-virtual-text").setup { + -- -- This just tries to mitigate the chance that I leak tokens here. Probably won't stop it from happening... + -- display_callback = function(variable) + -- local name = string.lower(variable.name) + -- local value = string.lower(variable.value) + -- if name:match "secret" or name:match "api" or value:match "secret" or value:match "api" then + -- return "*****" + -- end + -- + -- if #variable.value > 15 then + -- return " " .. string.sub(variable.value, 1, 15) .. "... " + -- end + -- + -- return " " .. variable.value + -- end, + -- } + + -- Handled by nvim-dap-go + -- dap.adapters.go = { + -- type = "server", + -- port = "${port}", + -- executable = { + -- command = "dlv", + -- args = { "dap", "-l", "127.0.0.1:${port}" }, + -- }, + -- } + + -- local elixir_ls_debugger = vim.fn.exepath "elixir-ls-debugger" + -- if elixir_ls_debugger ~= "" then + -- dap.adapters.mix_task = { + -- type = "executable", + -- command = elixir_ls_debugger, + -- } + -- + -- dap.configurations.elixir = { + -- { + -- type = "mix_task", + -- name = "phoenix server", + -- task = "phx.server", + -- request = "launch", + -- projectDir = "${workspaceFolder}", + -- exitAfterTaskReturns = false, + -- debugAutoInterpretAllModules = false, + -- }, + -- } + -- end + + vim.keymap.set("n", "b", dap.toggle_breakpoint) + vim.keymap.set("n", "gb", dap.run_to_cursor) + + -- Eval var under cursor + vim.keymap.set("n", "?", function() + require("dapui").eval(nil, { enter = true }) + end) + + vim.keymap.set("n", "", dap.continue) + vim.keymap.set("n", "", dap.step_into) + vim.keymap.set("n", "", dap.step_over) + vim.keymap.set("n", "", dap.step_out) + vim.keymap.set("n", "", dap.step_back) + vim.keymap.set("n", "", dap.restart) + + dap.listeners.before.attach.dapui_config = function() + ui.open() + end + dap.listeners.before.launch.dapui_config = function() + ui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + ui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + ui.close() + end + end, + }, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/fugitive.lua b/dot_config/nvim/lua/ibrahim/plugins/fugitive.lua new file mode 100644 index 0000000..13a8f18 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/fugitive.lua @@ -0,0 +1,6 @@ +return { + "tpope/vim-fugitive", + keys = { -- load the plugin only when using it's keybinding: + { "gs", vim.cmd.Git, desc = "Vim Fugitive" }, + }, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/gitsigns.lua b/dot_config/nvim/lua/ibrahim/plugins/gitsigns.lua new file mode 100644 index 0000000..dd89dfb --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/gitsigns.lua @@ -0,0 +1,20 @@ +return { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup({ + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + delay = 1000 / 3, + }, + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + }) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/gruvbox.lua b/dot_config/nvim/lua/ibrahim/plugins/gruvbox.lua new file mode 100644 index 0000000..a04d39c --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/gruvbox.lua @@ -0,0 +1 @@ +return { "ellisonleao/gruvbox.nvim", priority = 1000, config = true } diff --git a/dot_config/nvim/lua/ibrahim/plugins/harpoon.lua b/dot_config/nvim/lua/ibrahim/plugins/harpoon.lua new file mode 100644 index 0000000..695b69c --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/harpoon.lua @@ -0,0 +1,30 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local harpoon = require("harpoon") + harpoon:setup() + + vim.keymap.set("n", "a", function() + harpoon:list():add() + end, { desc = "Mark file with Harpoon" }) + + vim.keymap.set("n", "", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = "Open Harpoon menu" }) + + vim.keymap.set("n", "j", function() + harpoon:list():select(1) + end, { desc = "Open Harpoon file 1" }) + vim.keymap.set("n", "k", function() + harpoon:list():select(2) + end, { desc = "Open Harpoon file 2" }) + vim.keymap.set("n", "l", function() + harpoon:list():select(3) + end, { desc = "Open Harpoon file 3" }) + vim.keymap.set("n", ";", function() + harpoon:list():select(4) + end, { desc = "Open Harpoon file 4" }) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/jinja.lua b/dot_config/nvim/lua/ibrahim/plugins/jinja.lua new file mode 100644 index 0000000..295db2f --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/jinja.lua @@ -0,0 +1,3 @@ +return { + "lepture/vim-jinja", +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/lsp-lines.lua b/dot_config/nvim/lua/ibrahim/plugins/lsp-lines.lua new file mode 100644 index 0000000..e15055e --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/lsp-lines.lua @@ -0,0 +1,35 @@ +return { + url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + event = { "BufReadPre", "BufNewFile" }, + keys = { + -- The keys table here supports anything in the opts table for + -- vim.keymap.set, but be careful not to nest it in another table + -- like you would for that function. + -- { "di", desc = "Toggle [d]iagnostic [i]nline" }, + "di", + }, + opts = { + enabled = { + virtual_lines = true, + virtual_text = false, + }, + disabled = { + virtual_lines = false, + virtual_text = { spacing = 4, prefix = "●" }, + }, + }, + config = function(_, opts) + require("lsp_lines").setup() + local is_enabled = false + vim.diagnostic.config(opts.disabled) + + vim.keymap.set("n", "di", function() + is_enabled = not is_enabled + if is_enabled then + vim.diagnostic.config(opts.enabled) + else + vim.diagnostic.config(opts.disabled) + end + end, { desc = "Toggle [d]iagnostics [i]nline" }) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/lsp.lua b/dot_config/nvim/lua/ibrahim/plugins/lsp.lua new file mode 100644 index 0000000..a7fca1f --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/lsp.lua @@ -0,0 +1,377 @@ +-- return { +-- { +-- "VonHeikemen/lsp-zero.nvim", +-- branch = "v4.x", +-- lazy = true, +-- config = false, +-- }, +-- +-- { +-- "williamboman/mason.nvim", +-- lazy = false, +-- config = true, +-- }, +-- +-- -- Autocompletion +-- { +-- "hrsh7th/nvim-cmp", +-- event = { "InsertEnter", "CmdlineEnter" }, +-- dependencies = { +-- "L3MON4D3/LuaSnip", -- Snippet engine +-- "onsails/lspkind.nvim", -- Pretty formatting in the completion menu +-- +-- -- Completion sources +-- "hrsh7th/cmp-nvim-lsp", +-- "hrsh7th/cmp-nvim-lsp-signature-help", +-- "hrsh7th/cmp-buffer", +-- "hrsh7th/cmp-path", +-- "saadparwaiz1/cmp_luasnip", +-- }, +-- config = function() +-- local cmp = require("cmp") +-- local luasnip = require("luasnip") +-- +-- cmp.setup({ +-- completion = { +-- -- See :help completeopt +-- completeopt = "menu,menuone,noinsert,preview", +-- }, +-- snippet = { +-- expand = function(args) +-- luasnip.lsp_expand(args.body) +-- end, +-- }, +-- mapping = cmp.mapping.preset.insert({ +-- [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), +-- [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), +-- [""] = cmp.mapping.scroll_docs(-4), +-- [""] = cmp.mapping.scroll_docs(4), +-- +-- -- Ctrl+Space does not currently work in Neovim core on Windows +-- -- https://github.com/neovim/neovim/issues/8435 +-- -- [""] = cmp.mapping.complete(), +-- [""] = cmp.mapping.complete(), +-- +-- [""] = cmp.mapping.abort(), +-- [""] = cmp.mapping.confirm({ +-- -- Accept currently selected item +-- behavior = cmp.ConfirmBehavior.Insert, +-- select = true, +-- }), +-- [""] = cmp.mapping.confirm({ +-- -- Accept currently selected item, replacing stuff as needed +-- behavior = cmp.ConfirmBehavior.Replace, +-- select = true, +-- }), +-- [""] = cmp.mapping({ +-- -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#safely-select-entries-with-cr +-- i = function(fallback) +-- -- In insert mode, only use Enter to complete something if cmp +-- -- is active and the user has explicitly selected an item +-- if cmp.visible() and cmp.get_active_entry() then +-- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) +-- else +-- fallback() +-- end +-- end, +-- s = cmp.mapping.confirm({ select = true }), +-- c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), +-- }), +-- }), +-- sorting = { +-- priority_weight = 2, +-- comparators = { +-- cmp.config.compare.exact, +-- +-- -- Mostly default sort order from cmp +-- cmp.config.compare.offset, +-- -- cmp.config.compare.scopes, --this is commented in nvim-cmp too +-- cmp.config.compare.score, +-- cmp.config.compare.recently_used, +-- cmp.config.compare.locality, +-- cmp.config.compare.kind, +-- cmp.config.compare.sort_text, +-- cmp.config.compare.length, +-- cmp.config.compare.order, +-- }, +-- }, +-- sources = { +-- -- LSP results should be first priority +-- { name = "nvim_lsp", group_index = 1 }, +-- +-- { name = "nvim_lsp_signature_help", group_index = 2 }, +-- { name = "lazydev", group_index = 2 }, +-- { name = "luasnip", group_index = 2 }, +-- { name = "path", group_index = 2 }, +-- { name = "buffer", group_index = 2, keyword_length = 5 }, +-- }, +-- ---@diagnostic disable-next-line: missing-fields +-- formatting = { +-- format = require("lspkind").cmp_format({ +-- mode = "symbol_text", +-- maxwidth = function() +-- return math.floor(0.45 * vim.o.columns) +-- end, +-- ellipsis_char = "...", +-- show_labelDetails = true, +-- }), +-- }, +-- experimental = { +-- ghost_text = { +-- hl_group = "LspCodeLens", +-- }, +-- }, +-- window = { +-- completion = cmp.config.window.bordered(), +-- documentation = cmp.config.window.bordered(), +-- }, +-- }) +-- end, +-- }, +-- +-- -- LSP +-- { +-- "neovim/nvim-lspconfig", +-- cmd = { "LspInfo", "LspInstall", "LspStart" }, +-- event = { "BufReadPre", "BufNewFile" }, +-- dependencies = { +-- { "hrsh7th/cmp-nvim-lsp" }, +-- { "williamboman/mason.nvim" }, +-- { "williamboman/mason-lspconfig.nvim" }, +-- }, +-- config = function() +-- local lsp_zero = require("lsp-zero") +-- +-- lsp_zero.extend_lspconfig({ +-- sign_text = true, +-- capabilities = require("cmp_nvim_lsp").default_capabilities(), +-- }) +-- +-- local border = { +-- { "🭽", "FloatBorder" }, +-- { "▔", "FloatBorder" }, +-- { "🭾", "FloatBorder" }, +-- { "▕", "FloatBorder" }, +-- { "🭿", "FloatBorder" }, +-- { "▁", "FloatBorder" }, +-- { "🭼", "FloatBorder" }, +-- { "▏", "FloatBorder" }, +-- } +-- +-- local border_handlers = { +-- ["textDocument/hover"] = vim.lsp.buf.hover({ border = border }), +-- ["textDocument/signatureHelp"] = vim.lsp.buf.signature_help({ border = border }) +-- } +-- +-- require("mason-lspconfig").setup({ +-- automatic_enable = { "basedpyright", "ruff", "lua_ls" }, +-- handlers = { +-- -- this first function is the "default handler" +-- -- it applies to every language server without a "custom handler" +-- function(server_name) +-- require("lspconfig")[server_name].setup({ handlers = border_handlers }) +-- end, +-- +-- ["basedpyright"] = function() +-- local lspconfig = require("lspconfig") +-- lspconfig.basedpyright.setup({ +-- settings = { +-- basedpyright = { +-- typeCheckingMode = "standard", +-- }, +-- }, +-- }) +-- end, +-- }, +-- }) +-- vim.lsp.inlay_hint.enable() +-- end, +-- }, +-- +-- -- Formatting +-- { +-- "stevearc/conform.nvim", +-- config = function() +-- local conform = require("conform") +-- local prettier = { "prettierd", "prettier" } +-- conform.setup({ +-- formatters_by_ft = { +-- lua = { "stylua" }, +-- python = { "ruff_format", lsp_format = "fallback" }, +-- go = { "gopls" }, +-- rust = { "clippy", lsp_format = "fallback" }, +-- markdown = prettier, +-- }, +-- format_after_save = { +-- async = true, +-- stop_after_first = true, +-- lsp_format = "fallback", +-- }, +-- }) +-- +-- local function format() +-- conform.format({ async = true, lsp_fallback = true }) +-- end +-- +-- vim.keymap.set({ "n", "v" }, "rf", format, { desc = "Reformat" }) +-- vim.api.nvim_create_user_command("Format", format, {}) +-- end, +-- }, +-- +-- -- Lint +-- { +-- "mfussenegger/nvim-lint", +-- dependencies = { +-- -- Additional lua configuration, makes nvim stuff amazing! +-- "folke/neodev.nvim", +-- }, +-- event = { +-- "BufReadPre", +-- "BufNewFile", +-- }, +-- opts = { +-- autocmd = { +-- events = { "BufEnter", "BufWritePost" }, +-- pattern = { "*.py", "*.lua", "*.js", "*.ts", }, +-- linters_by_ft = { +-- python = { "mypy" }, +-- }, +-- }, +-- on_demand = { +-- linters_by_ft = { +-- python = { "mypy", "pylint" }, +-- }, +-- }, +-- }, +-- config = function(_, opts) +-- local lint = require("lint") +-- lint.linters_by_ft = { +-- javascript = { "eslint_d" }, +-- typescript = { "eslint_d" }, +-- } +-- +-- local function lint_autocmd() +-- local filetype = vim.bo.filetype +-- local linter_names = opts.autocmd.linters_by_ft[filetype] or {} +-- require("lint").try_lint(linter_names) +-- end +-- +-- local function lint_on_demand() +-- local filetype = vim.bo.filetype +-- local linter_names = opts.on_demand.linters_by_ft[filetype] or {} +-- require("lint").try_lint(linter_names) +-- end +-- +-- local lint_augroup = vim.api.nvim_create_augroup("user-nvim-lint", { clear = true }) +-- vim.api.nvim_create_autocmd(opts.autocmd.events, { +-- group = lint_augroup, +-- pattern = opts.autocmd.pattern, +-- callback = lint_autocmd, +-- }) +-- +-- vim.keymap.set("n", "cl", lint_on_demand, { desc = "[C]ode [l]int" }) +-- +-- -- Hate to remove this because I was pretty proud of it, but I'm removing +-- -- Pylint altogether. Since this is just my code, I'm leaving it here +-- -- as a reference if I want to mess with it again later. +-- -- -- I use Pylint consistently, and I have some projects that enforce +-- -- -- that Pylint must be passing. However, I don't always want to see +-- -- -- low-severity Pylint warnings like "missing docstring" for things +-- -- -- I'm still actively writing. They can be distracting. +-- -- -- +-- -- -- Build out a simple behavior that switches the Pylint arguments +-- -- -- to include or exclude Pylint's complexity (C) and conventions (R) +-- -- -- messages. +-- -- -- +-- -- -- I intentionally make this a global user command instead of a +-- -- -- buffer-specific one. +-- -- +-- -- local default_pylint_args = vim.deepcopy(lint.linters.pylint.args) +-- -- local simple_pylint_args = vim.deepcopy(lint.linters.pylint.args) +-- -- table.insert(simple_pylint_args, "--disable=C,R") +-- -- +-- -- local disable_pylint_low_severity = false +-- -- local function toggle_pylint_severity_mode() +-- -- disable_pylint_low_severity = not disable_pylint_low_severity +-- -- if disable_pylint_low_severity then +-- -- lint.linters.pylint.args = simple_pylint_args +-- -- print("Pylint mode changed to error/warning only") +-- -- else +-- -- lint.linters.pylint.args = default_pylint_args +-- -- print("Pylint mode reset to default") +-- -- end +-- -- -- Run the linter again to remove leftover messages or restore +-- -- -- newly added ones +-- -- lint.try_lint() +-- -- end +-- -- +-- -- vim.api.nvim_create_user_command("PylintSeverityToggle", toggle_pylint_severity_mode, {}) +-- end, +-- }, +-- +-- -- Code actions +-- { +-- "aznhe21/actions-preview.nvim", +-- config = function() +-- vim.keymap.set({ "v", "n" }, "ca", require("actions-preview").code_actions) +-- end, +-- }, +-- +-- -- Cool neovim dev stuff +-- { +-- "folke/lazydev.nvim", +-- ft = "lua", -- only load on lua files +-- opts = { +-- library = { +-- -- See the configuration section for more details +-- -- Load luvit types when the `vim.uv` word is found +-- { path = "luvit-meta/library", words = { "vim%.uv" } }, +-- }, +-- }, +-- }, +-- +-- { "Bilal2453/luvit-meta", lazy = true }, -- optional `vim.uv` typings +-- } +return { + + -- LSP + + { + "neovim/nvim-lspconfig" + }, + + { + "mason-org/mason.nvim", + opts = {} + }, + + { + "mason-org/mason-lspconfig.nvim", + dependencies = { + "neovim/nvim-lspconfig", + "mason-org/mason.nvim" + }, + opts = { + ensure_installed = { + "basedpyright", + "lua_ls", + "ruff", + "rust_analyzer" + } + } + }, + -- Cool neovim dev stuff + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "luvit-meta/library", words = { "vim%.uv" } }, + }, + }, + }, + + { "Bilal2453/luvit-meta", lazy = true }, -- optional `vim.uv` typings +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/mini.lua b/dot_config/nvim/lua/ibrahim/plugins/mini.lua new file mode 100644 index 0000000..dd1247f --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/mini.lua @@ -0,0 +1,8 @@ +return { + 'echasnovski/mini.nvim', + version = false, + config = function(_, opts) + -- Commenter + require("mini.comment").setup(opts) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/neotest.lua b/dot_config/nvim/lua/ibrahim/plugins/neotest.lua new file mode 100644 index 0000000..68e7bc3 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/neotest.lua @@ -0,0 +1,44 @@ +return { + "nvim-neotest/neotest", + ft = { "python" }, + dependencies = { + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", + "nvim-neotest/neotest-python", + "nvim-neotest/nvim-nio", + }, + opts = function() + return { + adapters = { + require("neotest-python")({ + -- Use the current Python binary on the path. + -- This will usually be a virtual environment. + python = "python", + runner = "pytest", + is_test_file = function(file_path) ---@param file_path string + -- I place all of my Python test files in a + -- `tests` directory, and they all start with + -- `test_` per Pytest conventions. + local normalized_path = vim.fs.normalize(file_path) + return normalized_path:match("tests/.*%/test_.*%.py$") ~= nil + end, + }), + }, + } + end, + config = function(_, opts) + require("neotest").setup(opts) + + vim.keymap.set({ "n" }, "tr", require("neotest").run.run, { desc = "Neotest: run test at cursor" }) + vim.keymap.set({ "n" }, "tf", function() + require("neotest").run.run(vim.fn.expand("%")) + end, { desc = "Neotest: run all tests in current file" }) + vim.keymap.set( + { "n" }, + "ts", + require("neotest").summary.toggle, + { desc = "Neotest: toggle summary panel" } + ) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/nvim-cmp.lua b/dot_config/nvim/lua/ibrahim/plugins/nvim-cmp.lua new file mode 100644 index 0000000..151e67b --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/nvim-cmp.lua @@ -0,0 +1,119 @@ +return { + "hrsh7th/nvim-cmp", + version = false, -- last release is way too old + event = { "InsertEnter", "CmdlineEnter" }, + dependencies = { + "L3MON4D3/LuaSnip", -- Snippet engine + "rafamadriz/friendly-snippets", -- Useful snippets in VSCode snippet format + "onsails/lspkind.nvim", -- Pretty formatting in the completion menu + + -- Completion sources + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lsp-signature-help", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + + -- Load any VSCode-style snippets from other installed plugins + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + -- See :help completeopt + completeopt = "menu,menuone,noinsert,preview", + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + + -- Ctrl+Space does not currently work in Neovim core on Windows + -- https://github.com/neovim/neovim/issues/8435 + -- [""] = cmp.mapping.complete(), + [""] = cmp.mapping.complete(), + + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ + -- Accept currently selected item + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), + [""] = cmp.mapping.confirm({ + -- Accept currently selected item, replacing stuff as needed + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping({ + -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#safely-select-entries-with-cr + i = function(fallback) + -- In insert mode, only use Enter to complete something if cmp + -- is active and the user has explicitly selected an item + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + }), + sorting = { + priority_weight = 2, + comparators = { + cmp.config.compare.exact, + + -- Mostly default sort order from cmp + cmp.config.compare.offset, + -- cmp.config.compare.scopes, --this is commented in nvim-cmp too + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + }, + sources = { + -- LSP results should be first priority + { name = "nvim_lsp", group_index = 1 }, + + { name = "nvim_lsp_signature_help", group_index = 2 }, + { name = "luasnip", group_index = 2 }, + { name = "path", group_index = 2 }, + { name = "buffer", group_index = 2, keyword_length = 5 }, + }, + formatting = { + format = require("lspkind").cmp_format({ + mode = "symbol_text", + -- maxwidth = 50, + maxwidth = function() + return math.floor(0.45 * vim.o.columns) + end, + ellipsis_char = "...", + show_labelDetails = true, + }), + }, + experimental = { + ghost_text = { + hl_group = "LspCodeLens", + }, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + }) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/nvim-colorizer.lua b/dot_config/nvim/lua/ibrahim/plugins/nvim-colorizer.lua new file mode 100644 index 0000000..465d0a9 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/nvim-colorizer.lua @@ -0,0 +1,6 @@ +return { + 'norcalli/nvim-colorizer.lua', + config = function() + require 'colorizer'.setup() + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/obsidian.lua.tmpl b/dot_config/nvim/lua/ibrahim/plugins/obsidian.lua.tmpl new file mode 100644 index 0000000..24982a6 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/obsidian.lua.tmpl @@ -0,0 +1,82 @@ +-- vim:ft=lua + +return { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = true, + ft = "markdown", + -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: + -- event = { + -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. + -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" + -- "BufReadPre path/to/my-vault/**.md", + -- "BufNewFile path/to/my-vault/**.md", + -- }, + keys = { + { "ob", vim.cmd.ObsidianBacklinks, desc = "Open Obsidian backlinks" }, + { "o/", vim.cmd.ObsidianSearch, desc = "Open Obsidian search" }, + { "op", vim.cmd.ObsidianQuickSwitch, desc = "Open Obsidian find files" }, + { "on", vim.cmd.ObsidianNew, desc = "Create new Obsidian note" }, + { "ot", vim.cmd.ObsidianToday, desc = "Open today's Obsidian daily note" }, + { "oy", vim.cmd.ObsidianYesterday, desc = "Open yesterday's Obsidian daily note" }, + { "ow", vim.cmd.ObsidianTomorrow, desc = "Open tomorrow's Obsidian daily note" }, + { "od", vim.cmd.ObsidianDailyNote, desc = "Open daily Obsidian note" }, + }, + dependencies = { + -- Required. + "nvim-lua/plenary.nvim", + + -- Optional + "hrsh7th/nvim-cmp", + "nvim-telescope/telescope.nvim", + "nvim-treesitter/nvim-treesitter", + }, + opts = { + workspaces = { + {{- if eq .chezmoi.os "windows" }} + { + name = "work", + path = "~/Documents/Vaults/Work", + }, + {{ else }} + { + name = "personal", + path = "~/Documents/Vaults/Personal", + }, + {{ end }} + }, + + ---@param title string + ---@return string + note_id_func = function(title) + local id = title:gsub(" ", "%-"):lower() + return id + end, + + templates = { + folder = "templates", + date_format = "%Y-%m-%d-%a", + substitutions = { + friendly_date_format = function() + return os.date("%A %B %d, %Y") + end + }, + }, + + daily_notes = { + folder = "dailies", + date_format = "%Y-%m-%d-%a", + alias_format = "%Y-%m-%d-%a", + template = "daily.md", + }, + + callbacks = { + enter_note = function() + -- The folds are too much for these notes + vim.opt_local.foldlevel = 99 + vim.opt_local.foldlevelstart = 99 + end, + }, + + }, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/oil.lua b/dot_config/nvim/lua/ibrahim/plugins/oil.lua new file mode 100644 index 0000000..ac41c0a --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/oil.lua @@ -0,0 +1,15 @@ +return { + "stevearc/oil.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + lazy = false, + config = function() + require("oil").setup { + keymaps = { + -- Disabling because I want Telescope to find files in Oil + [""] = false + } + } + + vim.keymap.set("n", "g-", "Oil", { desc = "Open parent directory" }) + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/telescope.lua b/dot_config/nvim/lua/ibrahim/plugins/telescope.lua new file mode 100644 index 0000000..89efb5c --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/telescope.lua @@ -0,0 +1,12 @@ +return { + 'nvim-telescope/telescope.nvim', branch = '0.1.x', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + -- Keymaps + local builtin = require 'telescope.builtin' + vim.keymap.set('n', '', builtin.find_files, { desc = 'Find files' }) + vim.keymap.set('n', '/', builtin.live_grep, { desc = 'Live Grep' }) + vim.keymap.set('n', 'vh', builtin.help_tags, { desc = 'Help menu' }) + end, +} + diff --git a/dot_config/nvim/lua/ibrahim/plugins/todo-comments.lua b/dot_config/nvim/lua/ibrahim/plugins/todo-comments.lua new file mode 100644 index 0000000..b47cb51 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/todo-comments.lua @@ -0,0 +1,6 @@ +return { + "folke/todo-comments.nvim", + event = "VimEnter", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { signs = false }, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/treesitter.lua b/dot_config/nvim/lua/ibrahim/plugins/treesitter.lua new file mode 100644 index 0000000..aade475 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/treesitter.lua @@ -0,0 +1,132 @@ +return { + "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + build = ":TSUpdate", + event = { "BufReadPre", "BufNewFile" }, + opts = { + -- List of parsers to install automatically + ensure_installed = { "lua", "vim", "vimdoc", "python", "json", "toml", "yaml", "bash", "javascript" }, + auto_install = true, + highlight = { + enable = true, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + indent = { + -- Syntax-aware indentation with the = operator + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "vn", + node_incremental = "n", + node_decremental = "", + scope_incremental = false, + }, + }, + textobjects = { + move = { + enable = true, + + -- Add jumps to the jumplist for navigating with Ctrl+I/O + set_jumps = true, + goto_next_start = { + ["]m"] = { query = "@call.outer", desc = "Next method/function call start" }, + ["]f"] = { query = "@function.outer", desc = "Next function def start" }, + ["]c"] = { query = "@class.outer", desc = "Next class start" }, + ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, + ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, + + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_next_end = { + ["]M"] = { query = "@call.outer", desc = "Next method/function call end" }, + ["]F"] = { query = "@function.outer", desc = "Next function def end" }, + ["]C"] = { query = "@class.outer", desc = "Next class end" }, + ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, + ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, + }, + goto_previous_start = { + ["[m"] = { query = "@call.outer", desc = "Previous method/function call start" }, + ["[f"] = { query = "@function.outer", desc = "Previous function def start" }, + ["[c"] = { query = "@class.outer", desc = "Previous class start" }, + ["[i"] = { query = "@conditional.outer", desc = "Previous conditional start" }, + ["[l"] = { query = "@loop.outer", desc = "Previous loop start" }, + }, + goto_previous_end = { + ["[M"] = { query = "@call.outer", desc = "Previous method/function call end" }, + ["[F"] = { query = "@function.outer", desc = "Previous function def end" }, + ["[C"] = { query = "@class.outer", desc = "Previous class end" }, + ["[I"] = { query = "@conditional.outer", desc = "Previous conditional end" }, + ["[L"] = { query = "@loop.outer", desc = "Previous loop end" }, + }, + }, + + select = { + enable = true, + + -- automatically jump forward to a text object if the + -- cursor isn't on one when triggering the plugin + lookahead = true, + + keymaps = { + -- Use = as an "assignment" text object + ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, + ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, + ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, + ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, + + -- Use "a" for "argument" + ["aa"] = { query = "@parameter.outer", desc = "Select outer part of an argument / parameter" }, + ["ia"] = { query = "@parameter.inner", desc = "Select inner part of an argument / parameter" }, + + -- Use "i" for "conditional" (saving c for class) + ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, + ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, + + -- Use "l" for "loop" + ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, + ["ij"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, + + -- Use "f" for "function definition" (body of a function) + ["af"] = { query = "@function.outer", desc = "Select outer part of a function definition" }, + ["if"] = { query = "@function.inner", desc = "Select inner part of a function definition" }, + + -- Use "m" for "method call" (invocation of a function) + ["am"] = { query = "@call.outer", desc = "Select outer part of a method/function call" }, + ["im"] = { query = "@call.inner", desc = "Select inner part of a method/function call" }, + + -- Use "c" for "class" + ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, + }, + }, + + swap = { + enable = true, + swap_next = { + ["na"] = "@parameter.inner", -- Swap parameter with next + ["nf"] = "@function.outer", -- Swap function with next + }, + swap_previous = { + ["pa"] = "@parameter.inner", -- Swap parameter with previous + ["pf"] = "@function.outer", -- Swap function with previous + }, + }, + }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + end, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/undotree.lua b/dot_config/nvim/lua/ibrahim/plugins/undotree.lua new file mode 100644 index 0000000..3465446 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/undotree.lua @@ -0,0 +1,8 @@ +return { + "jiaoshijie/undotree", + dependencies = "nvim-lua/plenary.nvim", + config = true, + keys = { -- load the plugin only when using it's keybinding: + { "u", "lua require('undotree').toggle()", desc = "Toggle Undotree" }, + }, +} diff --git a/dot_config/nvim/lua/ibrahim/plugins/which-key.lua b/dot_config/nvim/lua/ibrahim/plugins/which-key.lua new file mode 100644 index 0000000..7410159 --- /dev/null +++ b/dot_config/nvim/lua/ibrahim/plugins/which-key.lua @@ -0,0 +1,4 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", +} diff --git a/dot_config/nvim/lua/plugins/colorscheme.lua b/dot_config/nvim/lua/plugins/colorscheme.lua deleted file mode 100644 index 7cc5fd9..0000000 --- a/dot_config/nvim/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,2 +0,0 @@ --- return { "ellisonleao/gruvbox.nvim", priority = 1000, config = true } -return { "rose-pine/neovim", name = "rose-pine", priority = 1000, config = true } diff --git a/dot_config/nvim/lua/plugins/gitsigns.lua b/dot_config/nvim/lua/plugins/gitsigns.lua deleted file mode 100644 index dd89dfb..0000000 --- a/dot_config/nvim/lua/plugins/gitsigns.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "lewis6991/gitsigns.nvim", - config = function() - require("gitsigns").setup({ - current_line_blame = true, - current_line_blame_opts = { - virt_text = true, - delay = 1000 / 3, - }, - signs = { - add = { text = "┃" }, - change = { text = "┃" }, - delete = { text = "_" }, - topdelete = { text = "‾" }, - changedelete = { text = "~" }, - untracked = { text = "┆" }, - }, - }) - end, -} diff --git a/dot_config/nvim/lua/plugins/gruvbox.lua b/dot_config/nvim/lua/plugins/gruvbox.lua deleted file mode 100644 index a04d39c..0000000 --- a/dot_config/nvim/lua/plugins/gruvbox.lua +++ /dev/null @@ -1 +0,0 @@ -return { "ellisonleao/gruvbox.nvim", priority = 1000, config = true } diff --git a/dot_config/nvim/lua/plugins/harpoon.lua b/dot_config/nvim/lua/plugins/harpoon.lua deleted file mode 100644 index 695b69c..0000000 --- a/dot_config/nvim/lua/plugins/harpoon.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - "ThePrimeagen/harpoon", - branch = "harpoon2", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local harpoon = require("harpoon") - harpoon:setup() - - vim.keymap.set("n", "a", function() - harpoon:list():add() - end, { desc = "Mark file with Harpoon" }) - - vim.keymap.set("n", "", function() - harpoon.ui:toggle_quick_menu(harpoon:list()) - end, { desc = "Open Harpoon menu" }) - - vim.keymap.set("n", "j", function() - harpoon:list():select(1) - end, { desc = "Open Harpoon file 1" }) - vim.keymap.set("n", "k", function() - harpoon:list():select(2) - end, { desc = "Open Harpoon file 2" }) - vim.keymap.set("n", "l", function() - harpoon:list():select(3) - end, { desc = "Open Harpoon file 3" }) - vim.keymap.set("n", ";", function() - harpoon:list():select(4) - end, { desc = "Open Harpoon file 4" }) - end, -} diff --git a/dot_config/nvim/lua/plugins/jinja.lua b/dot_config/nvim/lua/plugins/jinja.lua deleted file mode 100644 index 295db2f..0000000 --- a/dot_config/nvim/lua/plugins/jinja.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - "lepture/vim-jinja", -} diff --git a/dot_config/nvim/lua/plugins/lsp-lines.lua b/dot_config/nvim/lua/plugins/lsp-lines.lua deleted file mode 100644 index e15055e..0000000 --- a/dot_config/nvim/lua/plugins/lsp-lines.lua +++ /dev/null @@ -1,35 +0,0 @@ -return { - url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim", - event = { "BufReadPre", "BufNewFile" }, - keys = { - -- The keys table here supports anything in the opts table for - -- vim.keymap.set, but be careful not to nest it in another table - -- like you would for that function. - -- { "di", desc = "Toggle [d]iagnostic [i]nline" }, - "di", - }, - opts = { - enabled = { - virtual_lines = true, - virtual_text = false, - }, - disabled = { - virtual_lines = false, - virtual_text = { spacing = 4, prefix = "●" }, - }, - }, - config = function(_, opts) - require("lsp_lines").setup() - local is_enabled = false - vim.diagnostic.config(opts.disabled) - - vim.keymap.set("n", "di", function() - is_enabled = not is_enabled - if is_enabled then - vim.diagnostic.config(opts.enabled) - else - vim.diagnostic.config(opts.disabled) - end - end, { desc = "Toggle [d]iagnostics [i]nline" }) - end, -} diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua deleted file mode 100644 index f74243e..0000000 --- a/dot_config/nvim/lua/plugins/lsp.lua +++ /dev/null @@ -1,334 +0,0 @@ -return { - { - "VonHeikemen/lsp-zero.nvim", - branch = "v4.x", - lazy = true, - config = false, - }, - - { - "williamboman/mason.nvim", - lazy = false, - config = true, - }, - - -- Autocompletion - { - "hrsh7th/nvim-cmp", - event = { "InsertEnter", "CmdlineEnter" }, - dependencies = { - "L3MON4D3/LuaSnip", -- Snippet engine - "onsails/lspkind.nvim", -- Pretty formatting in the completion menu - - -- Completion sources - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", - }, - config = function() - local cmp = require("cmp") - local luasnip = require("luasnip") - - cmp.setup({ - completion = { - -- See :help completeopt - completeopt = "menu,menuone,noinsert,preview", - }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - - -- Ctrl+Space does not currently work in Neovim core on Windows - -- https://github.com/neovim/neovim/issues/8435 - -- [""] = cmp.mapping.complete(), - [""] = cmp.mapping.complete(), - - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ - -- Accept currently selected item - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - [""] = cmp.mapping.confirm({ - -- Accept currently selected item, replacing stuff as needed - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping({ - -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#safely-select-entries-with-cr - i = function(fallback) - -- In insert mode, only use Enter to complete something if cmp - -- is active and the user has explicitly selected an item - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }), - }), - sorting = { - priority_weight = 2, - comparators = { - cmp.config.compare.exact, - - -- Mostly default sort order from cmp - cmp.config.compare.offset, - -- cmp.config.compare.scopes, --this is commented in nvim-cmp too - cmp.config.compare.score, - cmp.config.compare.recently_used, - cmp.config.compare.locality, - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - }, - sources = { - -- LSP results should be first priority - { name = "nvim_lsp", group_index = 1 }, - - { name = "nvim_lsp_signature_help", group_index = 2 }, - { name = "lazydev", group_index = 2 }, - { name = "luasnip", group_index = 2 }, - { name = "path", group_index = 2 }, - { name = "buffer", group_index = 2, keyword_length = 5 }, - }, - ---@diagnostic disable-next-line: missing-fields - formatting = { - format = require("lspkind").cmp_format({ - mode = "symbol_text", - maxwidth = function() - return math.floor(0.45 * vim.o.columns) - end, - ellipsis_char = "...", - show_labelDetails = true, - }), - }, - experimental = { - ghost_text = { - hl_group = "LspCodeLens", - }, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - }) - end, - }, - - -- LSP - { - "neovim/nvim-lspconfig", - cmd = { "LspInfo", "LspInstall", "LspStart" }, - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - { "hrsh7th/cmp-nvim-lsp" }, - { "williamboman/mason.nvim" }, - { "williamboman/mason-lspconfig.nvim" }, - }, - config = function() - local lsp_zero = require("lsp-zero") - - lsp_zero.extend_lspconfig({ - sign_text = true, - capabilities = require("cmp_nvim_lsp").default_capabilities(), - }) - - local border = { - { "🭽", "FloatBorder" }, - { "▔", "FloatBorder" }, - { "🭾", "FloatBorder" }, - { "▕", "FloatBorder" }, - { "🭿", "FloatBorder" }, - { "▁", "FloatBorder" }, - { "🭼", "FloatBorder" }, - { "▏", "FloatBorder" }, - } - - local border_handlers = { - ["textDocument/hover"] = vim.lsp.buf.hover({ border = border }), - ["textDocument/signatureHelp"] = vim.lsp.buf.signature_help({ border = border }) - } - - require("mason-lspconfig").setup({ - automatic_enable = { "basedpyright", "ruff", "lua_ls" }, - handlers = { - -- this first function is the "default handler" - -- it applies to every language server without a "custom handler" - function(server_name) - require("lspconfig")[server_name].setup({ handlers = border_handlers }) - end, - - ["basedpyright"] = function() - local lspconfig = require("lspconfig") - lspconfig.basedpyright.setup({ - settings = { - basedpyright = { - typeCheckingMode = "standard", - }, - }, - }) - end, - }, - }) - vim.lsp.inlay_hint.enable() - end, - }, - - -- Formatting - { - "stevearc/conform.nvim", - config = function() - local conform = require("conform") - local prettier = { "prettierd", "prettier" } - conform.setup({ - formatters_by_ft = { - lua = { "stylua" }, - python = { "ruff_format", lsp_format = "fallback" }, - go = { "gopls" }, - rust = { "clippy", lsp_format = "fallback" }, - markdown = prettier, - }, - format_after_save = { - async = true, - stop_after_first = true, - lsp_format = "fallback", - }, - }) - - local function format() - conform.format({ async = true, lsp_fallback = true }) - end - - vim.keymap.set({ "n", "v" }, "rf", format, { desc = "Reformat" }) - vim.api.nvim_create_user_command("Format", format, {}) - end, - }, - - -- Lint - { - "mfussenegger/nvim-lint", - dependencies = { - -- Additional lua configuration, makes nvim stuff amazing! - "folke/neodev.nvim", - }, - event = { - "BufReadPre", - "BufNewFile", - }, - opts = { - autocmd = { - events = { "BufEnter", "BufWritePost" }, - pattern = { "*.py", "*.lua", "*.js", "*.ts", }, - linters_by_ft = { - python = { "mypy" }, - }, - }, - on_demand = { - linters_by_ft = { - python = { "mypy", "pylint" }, - }, - }, - }, - config = function(_, opts) - local lint = require("lint") - lint.linters_by_ft = { - javascript = { "eslint_d" }, - typescript = { "eslint_d" }, - } - - local function lint_autocmd() - local filetype = vim.bo.filetype - local linter_names = opts.autocmd.linters_by_ft[filetype] or {} - require("lint").try_lint(linter_names) - end - - local function lint_on_demand() - local filetype = vim.bo.filetype - local linter_names = opts.on_demand.linters_by_ft[filetype] or {} - require("lint").try_lint(linter_names) - end - - local lint_augroup = vim.api.nvim_create_augroup("user-nvim-lint", { clear = true }) - vim.api.nvim_create_autocmd(opts.autocmd.events, { - group = lint_augroup, - pattern = opts.autocmd.pattern, - callback = lint_autocmd, - }) - - vim.keymap.set("n", "cl", lint_on_demand, { desc = "[C]ode [l]int" }) - - -- Hate to remove this because I was pretty proud of it, but I'm removing - -- Pylint altogether. Since this is just my code, I'm leaving it here - -- as a reference if I want to mess with it again later. - -- -- I use Pylint consistently, and I have some projects that enforce - -- -- that Pylint must be passing. However, I don't always want to see - -- -- low-severity Pylint warnings like "missing docstring" for things - -- -- I'm still actively writing. They can be distracting. - -- -- - -- -- Build out a simple behavior that switches the Pylint arguments - -- -- to include or exclude Pylint's complexity (C) and conventions (R) - -- -- messages. - -- -- - -- -- I intentionally make this a global user command instead of a - -- -- buffer-specific one. - -- - -- local default_pylint_args = vim.deepcopy(lint.linters.pylint.args) - -- local simple_pylint_args = vim.deepcopy(lint.linters.pylint.args) - -- table.insert(simple_pylint_args, "--disable=C,R") - -- - -- local disable_pylint_low_severity = false - -- local function toggle_pylint_severity_mode() - -- disable_pylint_low_severity = not disable_pylint_low_severity - -- if disable_pylint_low_severity then - -- lint.linters.pylint.args = simple_pylint_args - -- print("Pylint mode changed to error/warning only") - -- else - -- lint.linters.pylint.args = default_pylint_args - -- print("Pylint mode reset to default") - -- end - -- -- Run the linter again to remove leftover messages or restore - -- -- newly added ones - -- lint.try_lint() - -- end - -- - -- vim.api.nvim_create_user_command("PylintSeverityToggle", toggle_pylint_severity_mode, {}) - end, - }, - - -- Code actions - { - "aznhe21/actions-preview.nvim", - config = function() - vim.keymap.set({ "v", "n" }, "ca", require("actions-preview").code_actions) - end, - }, - - -- Cool neovim dev stuff - { - "folke/lazydev.nvim", - ft = "lua", -- only load on lua files - opts = { - library = { - -- See the configuration section for more details - -- Load luvit types when the `vim.uv` word is found - { path = "luvit-meta/library", words = { "vim%.uv" } }, - }, - }, - }, - - { "Bilal2453/luvit-meta", lazy = true }, -- optional `vim.uv` typings -} diff --git a/dot_config/nvim/lua/plugins/neotest.lua b/dot_config/nvim/lua/plugins/neotest.lua deleted file mode 100644 index 68e7bc3..0000000 --- a/dot_config/nvim/lua/plugins/neotest.lua +++ /dev/null @@ -1,44 +0,0 @@ -return { - "nvim-neotest/neotest", - ft = { "python" }, - dependencies = { - "nvim-lua/plenary.nvim", - "antoinemadec/FixCursorHold.nvim", - "nvim-treesitter/nvim-treesitter", - "nvim-neotest/neotest-python", - "nvim-neotest/nvim-nio", - }, - opts = function() - return { - adapters = { - require("neotest-python")({ - -- Use the current Python binary on the path. - -- This will usually be a virtual environment. - python = "python", - runner = "pytest", - is_test_file = function(file_path) ---@param file_path string - -- I place all of my Python test files in a - -- `tests` directory, and they all start with - -- `test_` per Pytest conventions. - local normalized_path = vim.fs.normalize(file_path) - return normalized_path:match("tests/.*%/test_.*%.py$") ~= nil - end, - }), - }, - } - end, - config = function(_, opts) - require("neotest").setup(opts) - - vim.keymap.set({ "n" }, "tr", require("neotest").run.run, { desc = "Neotest: run test at cursor" }) - vim.keymap.set({ "n" }, "tf", function() - require("neotest").run.run(vim.fn.expand("%")) - end, { desc = "Neotest: run all tests in current file" }) - vim.keymap.set( - { "n" }, - "ts", - require("neotest").summary.toggle, - { desc = "Neotest: toggle summary panel" } - ) - end, -} diff --git a/dot_config/nvim/lua/plugins/obsidian.lua.tmpl b/dot_config/nvim/lua/plugins/obsidian.lua.tmpl deleted file mode 100644 index 24982a6..0000000 --- a/dot_config/nvim/lua/plugins/obsidian.lua.tmpl +++ /dev/null @@ -1,82 +0,0 @@ --- vim:ft=lua - -return { - "epwalsh/obsidian.nvim", - version = "*", -- recommended, use latest release instead of latest commit - lazy = true, - ft = "markdown", - -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: - -- event = { - -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. - -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" - -- "BufReadPre path/to/my-vault/**.md", - -- "BufNewFile path/to/my-vault/**.md", - -- }, - keys = { - { "ob", vim.cmd.ObsidianBacklinks, desc = "Open Obsidian backlinks" }, - { "o/", vim.cmd.ObsidianSearch, desc = "Open Obsidian search" }, - { "op", vim.cmd.ObsidianQuickSwitch, desc = "Open Obsidian find files" }, - { "on", vim.cmd.ObsidianNew, desc = "Create new Obsidian note" }, - { "ot", vim.cmd.ObsidianToday, desc = "Open today's Obsidian daily note" }, - { "oy", vim.cmd.ObsidianYesterday, desc = "Open yesterday's Obsidian daily note" }, - { "ow", vim.cmd.ObsidianTomorrow, desc = "Open tomorrow's Obsidian daily note" }, - { "od", vim.cmd.ObsidianDailyNote, desc = "Open daily Obsidian note" }, - }, - dependencies = { - -- Required. - "nvim-lua/plenary.nvim", - - -- Optional - "hrsh7th/nvim-cmp", - "nvim-telescope/telescope.nvim", - "nvim-treesitter/nvim-treesitter", - }, - opts = { - workspaces = { - {{- if eq .chezmoi.os "windows" }} - { - name = "work", - path = "~/Documents/Vaults/Work", - }, - {{ else }} - { - name = "personal", - path = "~/Documents/Vaults/Personal", - }, - {{ end }} - }, - - ---@param title string - ---@return string - note_id_func = function(title) - local id = title:gsub(" ", "%-"):lower() - return id - end, - - templates = { - folder = "templates", - date_format = "%Y-%m-%d-%a", - substitutions = { - friendly_date_format = function() - return os.date("%A %B %d, %Y") - end - }, - }, - - daily_notes = { - folder = "dailies", - date_format = "%Y-%m-%d-%a", - alias_format = "%Y-%m-%d-%a", - template = "daily.md", - }, - - callbacks = { - enter_note = function() - -- The folds are too much for these notes - vim.opt_local.foldlevel = 99 - vim.opt_local.foldlevelstart = 99 - end, - }, - - }, -} diff --git a/dot_config/nvim/lua/plugins/oil.lua b/dot_config/nvim/lua/plugins/oil.lua deleted file mode 100644 index ac41c0a..0000000 --- a/dot_config/nvim/lua/plugins/oil.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "stevearc/oil.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - lazy = false, - config = function() - require("oil").setup { - keymaps = { - -- Disabling because I want Telescope to find files in Oil - [""] = false - } - } - - vim.keymap.set("n", "g-", "Oil", { desc = "Open parent directory" }) - end, -} diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua deleted file mode 100644 index 89efb5c..0000000 --- a/dot_config/nvim/lua/plugins/telescope.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'nvim-telescope/telescope.nvim', branch = '0.1.x', - dependencies = { 'nvim-lua/plenary.nvim' }, - config = function() - -- Keymaps - local builtin = require 'telescope.builtin' - vim.keymap.set('n', '', builtin.find_files, { desc = 'Find files' }) - vim.keymap.set('n', '/', builtin.live_grep, { desc = 'Live Grep' }) - vim.keymap.set('n', 'vh', builtin.help_tags, { desc = 'Help menu' }) - end, -} - diff --git a/dot_config/nvim/lua/plugins/todo-comments.lua b/dot_config/nvim/lua/plugins/todo-comments.lua deleted file mode 100644 index b47cb51..0000000 --- a/dot_config/nvim/lua/plugins/todo-comments.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - "folke/todo-comments.nvim", - event = "VimEnter", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { signs = false }, -} diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index aade475..0000000 --- a/dot_config/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,132 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - build = ":TSUpdate", - event = { "BufReadPre", "BufNewFile" }, - opts = { - -- List of parsers to install automatically - ensure_installed = { "lua", "vim", "vimdoc", "python", "json", "toml", "yaml", "bash", "javascript" }, - auto_install = true, - highlight = { - enable = true, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - indent = { - -- Syntax-aware indentation with the = operator - enable = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "vn", - node_incremental = "n", - node_decremental = "", - scope_incremental = false, - }, - }, - textobjects = { - move = { - enable = true, - - -- Add jumps to the jumplist for navigating with Ctrl+I/O - set_jumps = true, - goto_next_start = { - ["]m"] = { query = "@call.outer", desc = "Next method/function call start" }, - ["]f"] = { query = "@function.outer", desc = "Next function def start" }, - ["]c"] = { query = "@class.outer", desc = "Next class start" }, - ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, - ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, - - -- You can pass a query group to use query from `queries//.scm file in your runtime path. - -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. - ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, - ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, - }, - goto_next_end = { - ["]M"] = { query = "@call.outer", desc = "Next method/function call end" }, - ["]F"] = { query = "@function.outer", desc = "Next function def end" }, - ["]C"] = { query = "@class.outer", desc = "Next class end" }, - ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, - ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, - }, - goto_previous_start = { - ["[m"] = { query = "@call.outer", desc = "Previous method/function call start" }, - ["[f"] = { query = "@function.outer", desc = "Previous function def start" }, - ["[c"] = { query = "@class.outer", desc = "Previous class start" }, - ["[i"] = { query = "@conditional.outer", desc = "Previous conditional start" }, - ["[l"] = { query = "@loop.outer", desc = "Previous loop start" }, - }, - goto_previous_end = { - ["[M"] = { query = "@call.outer", desc = "Previous method/function call end" }, - ["[F"] = { query = "@function.outer", desc = "Previous function def end" }, - ["[C"] = { query = "@class.outer", desc = "Previous class end" }, - ["[I"] = { query = "@conditional.outer", desc = "Previous conditional end" }, - ["[L"] = { query = "@loop.outer", desc = "Previous loop end" }, - }, - }, - - select = { - enable = true, - - -- automatically jump forward to a text object if the - -- cursor isn't on one when triggering the plugin - lookahead = true, - - keymaps = { - -- Use = as an "assignment" text object - ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, - ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, - ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, - ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, - - -- Use "a" for "argument" - ["aa"] = { query = "@parameter.outer", desc = "Select outer part of an argument / parameter" }, - ["ia"] = { query = "@parameter.inner", desc = "Select inner part of an argument / parameter" }, - - -- Use "i" for "conditional" (saving c for class) - ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, - ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, - - -- Use "l" for "loop" - ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, - ["ij"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, - - -- Use "f" for "function definition" (body of a function) - ["af"] = { query = "@function.outer", desc = "Select outer part of a function definition" }, - ["if"] = { query = "@function.inner", desc = "Select inner part of a function definition" }, - - -- Use "m" for "method call" (invocation of a function) - ["am"] = { query = "@call.outer", desc = "Select outer part of a method/function call" }, - ["im"] = { query = "@call.inner", desc = "Select inner part of a method/function call" }, - - -- Use "c" for "class" - ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, - ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, - }, - }, - - swap = { - enable = true, - swap_next = { - ["na"] = "@parameter.inner", -- Swap parameter with next - ["nf"] = "@function.outer", -- Swap function with next - }, - swap_previous = { - ["pa"] = "@parameter.inner", -- Swap parameter with previous - ["pf"] = "@function.outer", -- Swap function with previous - }, - }, - }, - }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - vim.opt.foldmethod = "expr" - vim.opt.foldexpr = "nvim_treesitter#foldexpr()" - end, -} diff --git a/dot_config/nvim/lua/plugins/undotree.lua b/dot_config/nvim/lua/plugins/undotree.lua deleted file mode 100644 index 3465446..0000000 --- a/dot_config/nvim/lua/plugins/undotree.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "jiaoshijie/undotree", - dependencies = "nvim-lua/plenary.nvim", - config = true, - keys = { -- load the plugin only when using it's keybinding: - { "u", "lua require('undotree').toggle()", desc = "Toggle Undotree" }, - }, -} diff --git a/dot_config/nvim/lua/plugins/which-key.lua b/dot_config/nvim/lua/plugins/which-key.lua deleted file mode 100644 index 7410159..0000000 --- a/dot_config/nvim/lua/plugins/which-key.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - "folke/which-key.nvim", - event = "VeryLazy", -} diff --git a/dot_config/nvim/plugin/keymaps.lua b/dot_config/nvim/plugin/keymaps.lua deleted file mode 100644 index 38f25ce..0000000 --- a/dot_config/nvim/plugin/keymaps.lua +++ /dev/null @@ -1,165 +0,0 @@ --- Set leader key as Space -vim.g.mapleader = " " - -local function map(mode, left, right, opts) - local default_opts = { - noremap = true, - silent = true, - } - opts = opts or {} - -- "keep" mode preserves the values from the leftmost table, - -- so prioritize any options provided over the defaults - local full_opts = vim.tbl_extend("keep", opts, default_opts) - vim.keymap.set(mode, left, right, full_opts) -end - --- Clear any highlighted searches when pressing Esc --- This lets me leave hlsearch on by default while having an easy way to clear --- it again. -map({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) - --- Move lines while in visual mode with J and K -map("v", "J", ":m '>+1gv=gv") -map("v", "K", ":m '<-2gv=gv") - --- Easier execution of Lua code -map("n", "x", ".lua", { desc = "Execute the current line" }) -map("n", "x", "source %", { desc = "Execute the current file" }) - --- Keep cursor in the same place when using J to join lines -map("n", "J", "mzJ`z") - --- Center the screen when jumping around with C-d and C-u -map("n", "", "zz") -map("n", "", "zz") - --- Center the screen when jumping to next / previous search terms -map("n", "n", "nzzzv") -map("n", "N", "Nzzzv") - --- Quick maps to paste/delete without overwriting the current buffer -map("x", "p", '"_dP') -map({ "n", "v" }, "d", '"_dP') - --- Easier quickfix naviagion -map("n", "", "cprev", { desc = "Quickfix previous item" }) -map("n", "", "cnext", { desc = "Quickfix next item" }) - --- System clipboard -map({ "n", "v" }, "cd", '"+d', { desc = "Clipboard delete" }) -map({ "n", "v" }, "cp", '"+p', { desc = "Clipboard paste" }) -map({ "n", "v" }, "cy", '"+y', { desc = "Clipboard yank" }) - --- Map g- to netrw (temporary placeholder for oil) --- map("n", "g-", vim.cmd.Ex, { desc = "Open netrw" }) - -map("n", "gx", function() - local command = "go run " .. vim.fn.expand("%") - local f = assert(io.popen(command, "r")) - local s = assert(f:read("*a")) - f:close() - s = string.gsub(s, "^%s+", "") - s = string.gsub(s, "%s+$", "") - s = string.gsub(s, "[\n\r]+", " ") - print(s) -end, { desc = "Execute current go file" }) - - --- Create a GitHub URL for the current file and line number, and copy it --- to the clipboard. -map("n", "yfg", function() - local remote_url = vim.fn.system("git config --get remote.origin.url") - if not remote_url:find("github.com") then - vim.notify("This is not a GitHub repository") - return - end - - local trimmed_remote_url = remote_url:gsub("%.git", ""):gsub("%s+", ""):gsub("\n", "") - local branch_name = vim.fn.system("git rev-parse --abbrev-ref HEAD"):gsub("\n", "") - - -- Now construct the link in this format: - -- /blob//#L - - local filepath = vim.fn.expand("%:."):gsub("\\", "/") - - local line = vim.fn.line(".") - local result = trimmed_remote_url .. "/blob/" .. branch_name .. "/" .. filepath .. "#L" .. line - - vim.fn.setreg("+", result) - vim.notify("Copied GitHub URL to clipboard: " .. result) -end, { desc = "Yank GitHub URL to clipboard", expr = true }) - - --- LSP specific keybindings -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("IbrahimLspConfig", {}), - callback = function(evt) - local function lsp_map(mode, lhs, rhs, desc) - local opts = { buffer = evt.buf, desc = "LSP: " .. (desc or "") } - map(mode, lhs, rhs, opts) - end - - local has_telescope, _ = pcall(require, "telescope") - local function lsp_telescope_map(mode, lhs, with_telescope_rhs, no_telescope_rhs, desc) - if has_telescope then - desc = desc .. " (Telescope)" - lsp_map(mode, lhs, with_telescope_rhs, desc) - else - lsp_map(mode, lhs, no_telescope_rhs, desc) - end - end - local function tele_builtin(name, opts) - return function() - require("telescope.builtin")[name](opts) - end - end - - -- Navigation - lsp_map("n", "gd", vim.lsp.buf.definition, "[G]oto [D]efinition") - lsp_map("n", "gt", vim.lsp.buf.type_definition, "[G]oto [t]ype Definition") - lsp_map("n", "gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - lsp_map("n", "gr", vim.lsp.buf.references, "[G]oto [R]eferences") - lsp_map("n", "gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation") - - lsp_telescope_map("n", "gr", tele_builtin("lsp_references"), vim.lsp.buf.references, "Go to references") - lsp_telescope_map( - "n", - "sn", - tele_builtin("lsp_document_symbols"), - vim.lsp.buf.document_symbol, - "Search document symbols" - ) - lsp_telescope_map( - "n", - "sN", - tele_builtin("lsp_dynamic_workspace_symbols"), - vim.lsp.buf.workspace_symbol, - "Search workspace symbols" - ) - - -- Code changes - lsp_map("n", "cr", vim.lsp.buf.rename, "Rename") - -- ca is being overwritten by the 'actions-preview' plugin - -- lsp_map("n", "ca", vim.lsp.buf.code_action, "Code actions") - - -- Diagnostics - lsp_map("n", "ds", vim.diagnostic.open_float, "[s]how [d]iagnostic window") - lsp_map("n", "dn", function() - vim.diagnostic.goto_next({ float = true }) - end, "Go to [n]ext [d]iagnostic") - lsp_map("n", "dp", function() - vim.diagnostic.goto_prev({ float = true }) - end, "Go to [p]revious [d]iagnostic") - - -- See `:help K` for why this keymap - lsp_map("n", "K", vim.lsp.buf.hover, "Hover Documentation") - lsp_map("n", "", vim.lsp.buf.signature_help, "Signature Documentation") - - -- Workspace - lsp_map("n", "wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") - lsp_map("n", "wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") - lsp_map("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, "[W]orkspace [L]ist Folders") - end, -}) diff --git a/dot_config/nvim/plugin/options.lua b/dot_config/nvim/plugin/options.lua deleted file mode 100644 index 9e7252b..0000000 --- a/dot_config/nvim/plugin/options.lua +++ /dev/null @@ -1,35 +0,0 @@ -local opt = vim.opt - -opt.incsearch = true - -opt.number = true -opt.relativenumber = true - -opt.scrolloff = 8 - -vim.o.foldtext = "" -opt.foldlevelstart = 1 - -opt.conceallevel = 2 - -opt.tabstop = 4 -opt.softtabstop = 4 -opt.shiftwidth = 0 -opt.expandtab = true - -opt.autoindent = true -opt.smartindent = true -opt.breakindent = true - -opt.swapfile = false -opt.backup = false -opt.undodir = vim.fn.expand("~/.vim/undodir") -opt.undofile = true - -opt.ignorecase = true -opt.smartcase = true - -opt.updatetime = 250 - -vim.o.background = "dark" -vim.cmd([[colorscheme rose-pine]]) -- cgit v1.2.3