diff --git a/.config/nvim/.luacheckrc b/.config/nvim/.luacheckrc new file mode 100644 index 0000000..978e469 --- /dev/null +++ b/.config/nvim/.luacheckrc @@ -0,0 +1,3 @@ +std = "lua51" +globals = { "vim", "Snacks" } +max_line_length = false diff --git a/.config/nvim/.nvimlog b/.config/nvim/.nvimlog new file mode 100644 index 0000000..df078dc --- /dev/null +++ b/.config/nvim/.nvimlog @@ -0,0 +1,10 @@ +WRN 2026-02-24T11:33:23.184 ?.27376 server_start:199: Failed to start server: operation not permitted: /run/user/1000//nvim.27376.0 +WRN 2026-02-24T12:04:35.999 ?.29592 server_start:199: Failed to start server: operation not permitted: /run/user/1000//nvim.29592.0 +WRN 2026-08-28T15:33:15.778 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-28T15:38:46.688 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-28T16:08:02.008 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-28T16:08:06.345 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-28T16:41:19.378 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-31T13:42:03.306 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-31T13:42:57.702 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 +WRN 2026-08-31T13:43:16.053 ?.2 server_start:199: Failed to start server: operation not permitted: /run/user/1000/nvim.2.0 diff --git a/.config/nvim/.stylua.toml b/.config/nvim/.stylua.toml new file mode 100644 index 0000000..8adf588 --- /dev/null +++ b/.config/nvim/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Tabs" +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" diff --git a/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..210a7e3 --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1,50 @@ +# Neovim Config + +read_when: updating keymaps, startup order, or plugin layout + +## Load Order + +1. `init.lua` +2. `core.lazy` (bootstraps lazy.nvim, loads options) +3. colorscheme +4. `core.keymaps` (core editing, LSP, commands, and which-key groups) +5. `core.autocmds` +6. `core.highlights` +7. Hyprland LSP helper + +## Where To Edit + +- Options: `lua/core/options.lua` +- Autocmds: `lua/core/autocmds.lua` +- Highlights: `lua/core/highlights.lua` +- Keymaps entrypoint: `lua/core/keymaps/init.lua` +- Keymaps by domain: + - `lua/core/keymaps/editing.lua` + - `lua/core/keymaps/lsp.lua` + - `lua/core/keymaps/commands.lua` + - `lua/core/keymaps/groups.lua` +- Plugin setup and plugin-owned mappings: `lua/plugins/*.lua` + +## Structure Notes + +- Keep plugin specs in `lua/plugins/`. +- Keep core logic in `lua/core/`. +- Keep reusable helpers in `lua/utils/`. +- Put plugin mappings in the plugin spec's `keys` table so Lazy can load them on demand. +- Use `which-key` only to label mapping groups. + +## Tool Ownership + +- Formatting: Conform, with explicit formatters and no LSP fallback. +- Linting: nvim-lint on save. Codespell and pydoclint are linters. +- Completion: nvim-cmp with LuaSnip. None-ls is not part of completion. +- File browsing: Snacks Explorer. +- Notifications: Snacks Notifier. Fidget owns LSP progress, and Noice owns command/message UI. + +## Checks + +```sh +stylua --check . +luacheck . +nvim --headless -i NONE -u ./init.lua '+qa' +``` diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 0393630..e3ba6d5 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -3,9 +3,4 @@ vim.cmd("colorscheme catppuccin") require("core.keymaps") require("core.autocmds") require("core.highlights") --- require("core.lsp-notifications") -require("utils.extensions") -require("utils.telescope_extra").setup() -require("utils.functions.git_paste").setup({ telescope_key = "pg" }) --- require("utils.treesitter.parsers.hyprlang") require("utils.hyprland.lsp") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..79878b7 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,60 @@ +{ + "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, + "any-jump.vim": { "branch": "master", "commit": "f95674d9a4251ac02f452d5f1861e4422f4652c7" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "catppuccin": { "branch": "main", "commit": "edefef779ab08ce1a4a404713e3012b0d202bd35" }, + "cmp-async-path": { "branch": "main", "commit": "98185a91d49ff5dd249aebf2f7456e18063fa2a0" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "fd3e882e56956675c620898bf1ffcf4fcbe7ec84" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "codecompanion.nvim": { "branch": "main", "commit": "6eec6b429de1340096553036a7aa3b08067eab32" }, + "conform.nvim": { "branch": "master", "commit": "016802de402556da54c36bd7359b441266b01cdd" }, + "copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" }, + "copilot-lualine": { "branch": "main", "commit": "222e90bd8dcdf16ca1efc4e784416afb5f011c31" }, + "copilot.lua": { "branch": "master", "commit": "7e6723aabea044519462958ffcea68d7985c5ed0" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "fidget.nvim": { "branch": "main", "commit": "6f793b2bcd2d35e201c09520f698bb763220908a" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "gitsigns.nvim": { "branch": "main", "commit": "5be654f2232c10ddcad19c1607a67b6b4b78fc29" }, + "goto-preview": { "branch": "main", "commit": "d2d6923c9b9e0e43f0b9b566f261a8b1ae016540" }, + "image.nvim": { "branch": "master", "commit": "5c6f29a5069e1f7bd5773ce5907454063b0f125d" }, + "img-clip.nvim": { "branch": "main", "commit": "b6ddfb97b5600d99afe3452d707444afda658aca" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, + "lspkind.nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, + "mcphub.nvim": { "branch": "main", "commit": "7cd5db330f41b7bae02b2d6202218a061c3ebc1f" }, + "mini.diff": { "branch": "main", "commit": "626b8a5b93874c4d05ca25aedec56cfff0b378fb" }, + "mini.nvim": { "branch": "main", "commit": "a311ed247d527db9592bb434356badc705363746" }, + "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, + "nui.nvim": { "branch": "main", "commit": "10fc361835c856ba4233ef5ea135b919bf3dce97" }, + "nvim-autopairs": { "branch": "master", "commit": "430522f95fe4fb7c511ec64f8c1a90cc6a66c05c" }, + "nvim-cmp": { "branch": "main", "commit": "2ffe79f1f021def8dd1fcd81deb16f1bb0d989f3" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, + "nvim-html-css": { "branch": "main", "commit": "3f246f6166e75fb8afc1866ce8f1e4cb8d95757a" }, + "nvim-lint": { "branch": "master", "commit": "3d55c8f67c6ae5c15e1042571e107c7a3d5c5f4e" }, + "nvim-lspconfig": { "branch": "master", "commit": "16286347bdba1333c7d124d9de9fe6630731b2b2" }, + "nvim-nio": { "branch": "master", "commit": "edcc181a875301dd21840189aa2f2f9ad69fc172" }, + "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, + "nvim-treesitter-context": { "branch": "master", "commit": "f3061339b8eaf9fda873600bc425b8d2d8502533" }, + "nvim-web-devicons": { "branch": "master", "commit": "5f032a85be210cd1c6ac98861eb3b187ff3bd5eb" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "012f1480cd9a5fc99fce7678e0a536421a53fc46" }, + "render-markdown.nvim": { "branch": "main", "commit": "4663eb3ecd538bd5062628fb6d95bbe6bdca78f6" }, + "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, + "telescope-color-names.nvim": { "branch": "main", "commit": "95b372b9a8ba0fc7cf6a67be637ee37453f322da" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, + "telescope-glyph.nvim": { "branch": "master", "commit": "6e0bdece0d0382e664b2dc716a9c5641994148c9" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "40aedd8a68c78a656a10a8d62d80c54af59420fb" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, + "vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" }, + "vim-dotenv": { "branch": "master", "commit": "5c51cfcf8d87280d6414e03cd6b253eb70ecb800" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-wakatime": { "branch": "master", "commit": "9f8a1d3b9c6f3a948988a0896b3227c1e1f74a58" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/.config/nvim/lua/core/autocmds.lua b/.config/nvim/lua/core/autocmds.lua index fd6a600..997b669 100644 --- a/.config/nvim/lua/core/autocmds.lua +++ b/.config/nvim/lua/core/autocmds.lua @@ -39,29 +39,13 @@ autocmd("TextYankPost", { group = highlight_yank, pattern = "*", callback = function() - vim.highlight.on_yank({ higroup = "IncSearch", timeout = 420 }) + vim.hl.on_yank({ higroup = "IncSearch", timeout = 420 }) end, }) -- }}} --- {{{ Disable indent-blankline for dashboard -function disable_for_dashboard() - local buftype = vim.api.nvim_buf_get_option(0, "buftype") - local filetype = vim.api.nvim_buf_get_option(0, "filetype") - if buftype == "nofile" and filetype == "dashboard" then - vim.b.indent_blankline_enabled = false - end -end -vim.cmd([[ - augroup IndentBlankline - autocmd! - autocmd FileType dashboard lua disable_for_dashboard() - augroup END -]]) --- }}} - -- {{{ Code companion hook -local group = augroup("CodeCompanionHooks", {}) +local group = augroup("CodeCompanionHooks", { clear = true }) autocmd({ "User" }, { pattern = "CodeCompanionInline*", diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua deleted file mode 100644 index 8d05b12..0000000 --- a/.config/nvim/lua/core/keymaps.lua +++ /dev/null @@ -1,681 +0,0 @@ -local map = vim.keymap.set -local map_from_table = require("utils.keymaps.converters.from_table").set_keybindings -local add_to_whichkey = require("utils.keymaps.converters.whichkey").addToWhichKey -local telescope_paste_img = require("utils.telescope_extra").find_and_paste_image -local mkdir_under_cursor = require("utils.functions.mkdir_under_cursor").setup() -local term = require("utils.terminal") -local term_factory = term.term_factory -local term_toggle = term.term_toggle - -local nosilent = { silent = false, noremap = true } - --- Leader key -vim.g.mapleader = " " -vim.g.maplocalleader = "," - --- Create a custom command with the given trigger, command, and description ---- @param trigger string The command trigger ---- @param command string The command to execute ---- @param description string Description of the command ---- @return nil -local create_custom_command = function(trigger, command, description) - vim.api.nvim_create_user_command(trigger, command, { desc = description }) -end --- Custom commands -create_custom_command("Config", "edit ~/.config/nvim", "Edit nvim configuration") -create_custom_command("Keymaps", "edit ~/.config/nvim/lua/core/keymaps.lua", "Edit Hyprland keybindings") -create_custom_command("Hypr", "edit ~/.config/hypr/hyprland.conf", "Edit Hyprland configuration") - -vim.keymap.set("", "tl", function() - vim.diagnostic.enable(not vim.diagnostic.is_enabled()) -end, { desc = "Toggle diagnostics virtual text" }) - --- {{{ Basic Mappings -local basic_mappings = { - { key = "", cmd = "zz", desc = "Scroll up and center", mode = "n" }, - { key = "n", cmd = "nzzzv", desc = "Next search result and center", mode = "n" }, - { key = "N", cmd = "Nzzzv", desc = "Previous search result and center", mode = "n" }, - { key = "pp", cmd = '"_dP', desc = "Paste without yanking", mode = "x" }, - { key = "<", cmd = "")) - end, - group = "Generate Stub File", - }, -} --- }}} - --- {{{ Code Companion Mappings -local code_companion_mappings = { - { mode = "n", key = "cp", cmd = ":vert Copilot panel", group = "Copilot Panel" }, - { - mode = "n", - key = "Cf", - cmd = function() - local chat = require("codecompanion").chat - chat({ window_opts = { height = 1.0, layout = "buffer" } }) - end, - group = "Codecompanion Fullscreen", - }, - { - mode = "n", - key = "Ch", - cmd = function() - local chat = require("codecompanion").chat - chat({ window_opts = { height = 0.24, layout = "horizontal", position = "bottom" } }) - end, - group = "Codecompanion Horizontal Split", - }, - { mode = "n", key = "Cc", cmd = ":CodeCompanionChat Toggle", group = "Toggle Codecompanion" }, - { mode = "n", key = "oc", cmd = ":CodeCompanionChat Toggle", group = "Toggle Codecompanion" }, - { - mode = "n", - key = "Ci", - cmd = function() - vim.api.nvim_feedkeys(":CodeCompanion #{buffer} ", "n", false) - end, - group = "Inline CodeCompanion", - opts = nosilent, - }, - { mode = "n", key = "Ct", cmd = ":CodeCompanionChat Toggle", group = "CodeCompanion Toggle" }, - { mode = "n", key = "CA", cmd = ":CodeCompanionActions", group = "CodeCompanion Actions" }, - { mode = "v", key = "Ca", cmd = ":CodeCompanionChat Add", group = "CodeCompanion Add" }, - { - mode = "v", - key = "Ci", - cmd = function() - vim.api.nvim_feedkeys(":CodeCompanion #{buffer} ", "n", false) - end, - group = "CodeCompanion Inline", - opts = nosilent, - }, - { mode = "v", key = "Ce", cmd = ":CodeCompanion /explain", group = "CodeCompanion /explain" }, - { mode = "v", key = "Cf", cmd = ":CodeCompanion /fix", group = "CodeCompanion /fix" }, - { mode = "v", key = "Cl", cmd = ":CodeCompanion /lsp", group = "CodeCompanion /lsp" }, - { mode = "v", key = "Ct", cmd = ":CodeCompanion /tests", group = "CodeCompanion /tests" }, -} --- }}} - --- {{{ Telescope mappings -local telescope_mappings = { - { - mode = "n", - key = "//", - cmd = ":Telescope current_buffer_fuzzy_find previewer=false", - desc = "Current buffer fuzzy find", - }, - { - mode = "n", - key = "??", - cmd = ":Telescope lsp_document_symbols theme=dropdown layout_config={width=0.5}", - group = "Lsp document symbols", - }, - { - mode = "n", - key = "fc", - cmd = ':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical', - group = "Telescope color names", - }, - { - mode = "n", - key = "Tc", - cmd = ":Telescope colorscheme", - group = "Telescope colorscheme", - }, - { - mode = "n", - key = "TC", - cmd = ':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical', - group = "Telescope color names", - }, - { - mode = "n", - key = "Tn", - cmd = ":Telescope notify theme=dropdown layout_config={width=0.75}", - group = "Telescope notify", - }, - { - mode = "n", - key = "TN", - cmd = ":Telescope noice theme=dropdown layout_config={width=0.75}", - group = "Telescope Noice", - }, - { - mode = "n", - key = "Ti", - cmd = function() - telescope_paste_img() - end, - desc = "Find and Paste Image", - }, - { - mode = "n", - key = "ff", - cmd = ":Telescope find_files find_command=rg,--ignore,--follow,--hidden,--files prompt_prefix=🔍", - group = "Find files", - }, - { mode = "n", key = "fg", cmd = ":Telescope live_grep", group = "Live Grep" }, - { - mode = "n", - key = "Tg", - cmd = ':Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical', - group = "Telescope Glyph", - }, - { - mode = "n", - key = "fG", - cmd = ':Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical', - group = "Glhph", - }, - { mode = "n", key = "fb", cmd = ":Telescope file_browser", group = "File browser" }, - { - mode = "n", - key = "fr", - cmd = ":Telescope oldfiles theme=dropdown layout_config={width=0.5}", - group = "Oldfiles", - }, - { - mode = "n", - key = "hc", - cmd = ":Telescope commands", - group = "Commands", - }, - { - mode = "n", - key = "hv", - cmd = ":Telescope vim_options", - group = "Vim options", - }, - { - mode = "n", - key = "hk", - cmd = ":Telescope keymaps", - group = "Keymaps", - }, - { - mode = "n", - key = "hs", - cmd = ":Telescope spell_suggest", - group = "Spell suggest", - }, - { - mode = "n", - key = "ht", - cmd = ":Telescope help_tags", - group = "Help tags", - }, - { - mode = "n", - key = "hm", - cmd = ":Telescope man_pages theme=dropdown layout_config={width=0.75}", - group = "Man pages", - }, - { - mode = "n", - key = "sf", - cmd = ":Telescope find_files find_command=rg,--ignore,--follow,--hidden,--files prompt_prefix=🔍", - group = "Search files", - }, - { mode = "n", key = "sF", cmd = ":Telescope fidget", group = "Fidget" }, - { mode = "n", key = "sg", cmd = ":Telescope live_grep", group = "Live grep" }, - { mode = "n", key = "sh", cmd = ":Telescope command_history", group = "Command history" }, - { - mode = "n", - key = "sn", - cmd = function() - Snacks.win({ - file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1], - width = 0.6, - height = 0.6, - wo = { - spell = false, - wrap = false, - signcolumn = "yes", - statuscolumn = " ", - conceallevel = 3, - }, - }) - end, - group = "News", - }, - { mode = "n", key = "sm", cmd = ":Telescope man_pages", group = "Man pages" }, - { mode = "n", key = "s/", cmd = ":Telescope search_history", group = "Search history" }, - { mode = "n", key = "gc", cmd = ":Telescope git_commits", group = "Git commits" }, - { mode = "n", key = "gf", cmd = ":Telescope git_files", group = "Git files" }, - { mode = "n", key = "Tr", cmd = ":Telescope reloader", group = "Telescope reloader" }, -} ---}}} - --- {{{ File Explorer Mappings (i guess) -local file_explorer_mappings = { - { mode = "n", key = "nt", cmd = ":NvimTreeToggle" }, - { mode = "n", key = "nc", cmd = ":lua Snacks.notifier.hide()" }, - { mode = "n", key = "nh", cmd = ":lua Snacks.notifier.show_history()" }, -} --- }}} - --- {{{ Misc Utilities Mappings -local misc_utilities_mappings = { - { mode = "n", key = "x", cmd = "!chmod +x %", group = "Make Executable" }, - { mode = "n", key = "y", cmd = '"+y', group = "System Yank" }, - { mode = "v", key = "y", cmd = '"+y', group = "System Yank" }, - { mode = "n", key = "sc", cmd = ":nohls", group = "Search" }, - { - mode = "n", - key = "m", - cmd = function() - mkdir_under_cursor() - end, - group = "mkdir under cursor", - }, - { - mode = "v", - key = "m", - cmd = function() - mkdir_under_cursor() - end, - group = "mkdir selection", - }, -} --- }}} - --- {{{ Goto Preview Mappings -local goto_preview_mappings = { - { mode = "n", key = "gpc", cmd = ':lua require("goto-preview").close_all_win()', group = "Goto Preview" }, - { - mode = "n", - key = "gpd", - cmd = ':lua require("goto-preview").goto_preview_definition()', - group = "Goto Preview", - }, - { - mode = "n", - key = "gpi", - cmd = ':lua require("goto-preview").goto_preview_implementation()', - group = "Goto Preview", - }, -} --- }}} - --- {{{ Workspace Management Mappings -local workspace_management_mappings = { - { mode = "n", key = "wa", cmd = vim.lsp.buf.add_workspace_folder }, - { mode = "n", key = "wr", cmd = vim.lsp.buf.remove_workspace_folder }, - { - mode = "n", - key = "wl", - cmd = function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, - }, -} --- }}} - --- {{{ Noice Mappings -local noice_mappings = { - { mode = "n", key = "Nh", cmd = ":Noice telescope", group = "Noice" }, - { mode = "n", key = "Nl", cmd = ":Noice last", group = "Noice" }, - { mode = "n", key = "Nd", cmd = ":Noice dismiss", group = "Noice" }, - { mode = "n", key = "Ne", cmd = ":Noice errors", group = "Noice" }, - { mode = "n", key = "Ns", cmd = ":Noice stats", group = "Noice" }, -} --- }}} - --- {{{ ODIS Mappings -local odis_mappings = { - { - mode = "n", - key = "dv", - cmd = ':lua require("odis").show_documentation("vsplit")', - group = "Vertical split", - }, - { mode = "n", key = "dh", cmd = ':lua require("odis").show_documentation("split")', group = "Split" }, - { mode = "n", key = "db", cmd = ':lua require("odis").show_documentation("buffer")', group = "Buffer" }, - { mode = "n", key = "dt", cmd = ':lua require("odis").show_documentation("tab")', group = "Tab" }, - { mode = "n", key = "df", cmd = ':lua require("odis").show_documentation("float")', group = "Float" }, -} --- }}} - --- {{{ Diffview Mappings -local diffview_mappings = { - { - - mode = "n", - key = "gdo", - cmd = ":DiffviewOpen", - group = "DiffviewOpen", - }, - { - - mode = "n", - key = "gdf", - cmd = ":DiffviewFileHistory %", - group = "Git", - }, - { - - mode = "n", - key = "gdh", - cmd = ":DiffviewHistory", - group = "Git", - }, - { - - mode = "n", - key = "gdc", - cmd = ":DiffviewClose", - group = "Git", - }, - { - - mode = "n", - key = "gdt", - cmd = ":DiffviewToggleFiles", - group = "Git", - desc = "Toggle files view", - }, - { - - mode = "n", - key = "gdr", - cmd = ":DiffviewRefresh", - desc = "Refresh diffview", - group = "Git", - }, - { - mode = "n", - key = "gg", - cmd = ":lua Snacks.lazygit()", - desc = "Open Lazygit", - }, -} --- }}} - ---{{{ Custom Terminals -local programs_map = { - op = { cmd = "ipython", display_name = "ipython", direction = "vertical", hidden = true }, - oP = { - cmd = "ipython", - display_name = "ipython-full", - direction = "tab", - hidden = true, - }, - oi = { cmd = "sudo iotop", display_name = "iotop", direction = "tab", hidden = true }, - on = { cmd = "rmpc", display_name = "rmpc", direction = "tab", hidden = true }, - oN = { cmd = "nvtop", display_name = "nvtop", direction = "tab", hidden = true }, - ob = { cmd = "/usr/bin/btop", display_name = "btop", direction = "tab", hidden = true }, - od = { cmd = "lazydocker", display_name = "lazydocker", direction = "tab", hidden = true }, -} - -local temp -local tbl = {} -for key, value in pairs(programs_map) do - temp = { - cmd = function() - term_toggle(term_factory(value)) - end, - key = "" .. key, - group = value.group, - mode = "n", - desc = "Open " .. value.display_name, - } - table.insert(tbl, temp) -end -add_to_whichkey(tbl, { key = "o", group = "Open" }) - -function _G.set_terminal_keymaps() - local opts = { buffer = 0 } - map("t", "", [[]], opts) - map("t", "", [[]], opts) -end - -vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") ---}}} - --- {{{ IMAGE -local image_mappings = { - { - - mode = "n", - key = "id", - cmd = ":lua require('image').disable()", - desc = "Disable image rendering", - }, - { - - mode = "n", - key = "ie", - cmd = ":lua require('image').enable()", - desc = "Enable image rendering", - }, - { - mode = "n", - key = "pi", - cmd = function() - telescope_paste_img() - end, - desc = "Find and Paste Image", - }, -} --- }}} - ---{{{ Groups -add_to_whichkey(nil, { key = "a", group = "AnyJump" }) -add_to_whichkey(nil, { key = "b", group = "Buffers" }) -add_to_whichkey(nil, { key = "c", group = "Code" }) -add_to_whichkey(nil, { key = "ca", group = "Code Actions" }) -add_to_whichkey(nil, { key = "cc", group = "Calls" }) -add_to_whichkey(nil, { key = "C", group = "CodeCompanion" }) -add_to_whichkey(nil, { key = "cL", group = "LSP" }) -add_to_whichkey(nil, { key = "d", group = "ODIS" }) -add_to_whichkey(nil, { key = "f", group = "Find" }) -add_to_whichkey(nil, { key = "g", group = "Git" }) -add_to_whichkey(nil, { key = "gd", group = "DiffView" }) -add_to_whichkey(nil, { key = "h", group = "Help" }) -add_to_whichkey(nil, { key = "i", group = "Image" }) -add_to_whichkey(nil, { key = "j", group = "AnyJump" }) -add_to_whichkey(nil, { key = "N", group = "Noice" }) --- add_to_whichkey(nil, { key = "o", group = "Open" }) -add_to_whichkey(nil, { key = "p", group = "Paste" }) -add_to_whichkey(nil, { key = "pg", group = "Paste Git Raw" }) -add_to_whichkey(nil, { key = "s", group = "Search" }) -add_to_whichkey(nil, { key = "t", group = "Terminal" }) -add_to_whichkey(nil, { key = "T", group = "Telescope" }) -add_to_whichkey(nil, { key = "w", group = "Workspace" }) -add_to_whichkey(nil, { key = "x", group = "Make Executable" }) -add_to_whichkey(nil, { key = "y", group = "System Yank" }) -add_to_whichkey(nil, { key = "0", group = "Horizontal Terminal" }) -add_to_whichkey(nil, { key = "cP", group = "Python" }) ---}}} - ---{{{ Whichkey Mappings -local mappings_tables = { - basic_mappings, - buffer_navigation_mappings, - terminal_mappings, - lsp_mappings, - code_companion_mappings, - telescope_mappings, - file_explorer_mappings, - misc_utilities_mappings, - goto_preview_mappings, - workspace_management_mappings, - noice_mappings, - odis_mappings, - diffview_mappings, - image_mappings, -} - -for _, mapping in ipairs(mappings_tables) do - add_to_whichkey(map_from_table(mapping)) -end -add_to_whichkey(nil, { key = "dc", group = "Close" }) ---}}} diff --git a/.config/nvim/lua/core/keymaps/commands.lua b/.config/nvim/lua/core/keymaps/commands.lua new file mode 100644 index 0000000..5edb4c5 --- /dev/null +++ b/.config/nvim/lua/core/keymaps/commands.lua @@ -0,0 +1,21 @@ +local M = {} + +function M.setup() + vim.api.nvim_create_user_command("Config", "edit ~/.config/nvim", { desc = "Edit Neovim configuration" }) + vim.api.nvim_create_user_command( + "Keymaps", + "edit ~/.config/nvim/lua/core/keymaps/init.lua", + { desc = "Edit keymaps" } + ) + vim.api.nvim_create_user_command( + "Hypr", + "edit ~/.config/hypr/hyprland.conf", + { desc = "Edit Hyprland configuration" } + ) + + vim.keymap.set("", "tl", function() + vim.diagnostic.enable(not vim.diagnostic.is_enabled()) + end, { desc = "Toggle diagnostics" }) +end + +return M diff --git a/.config/nvim/lua/core/keymaps/editing.lua b/.config/nvim/lua/core/keymaps/editing.lua new file mode 100644 index 0000000..d93226e --- /dev/null +++ b/.config/nvim/lua/core/keymaps/editing.lua @@ -0,0 +1,38 @@ +local M = {} + +local map = vim.keymap.set + +function M.setup() + map("n", "", "zz", { desc = "Scroll up and center" }) + map("n", "n", "nzzzv", { desc = "Next search result and center" }) + map("n", "N", "Nzzzv", { desc = "Previous search result and center" }) + map("x", "pp", '"_dP', { desc = "Paste without yanking" }) + map("v", "<", "", ">gv", { desc = "Reselect after indent" }) + map("v", "J", ":m '>+1gv=gv", { desc = "Move line down" }) + map("v", "K", ":m '<-2gv=gv", { desc = "Move line up" }) + + map("n", "", "bnext", { desc = "Next buffer" }) + map("n", "", "bprevious", { desc = "Previous buffer" }) + map("n", "bk", "bdelete", { desc = "Delete buffer" }) + map("n", "bn", "bnext", { desc = "Next buffer" }) + map("n", "bp", "bprevious", { desc = "Previous buffer" }) + + map("n", "x", "!chmod +x %", { desc = "Make file executable" }) + map({ "n", "v" }, "y", '"+y', { desc = "Yank to system clipboard" }) + map("n", "sc", "nohlsearch", { desc = "Clear search highlights" }) + map({ "n", "v" }, "m", require("utils.functions.mkdir_under_cursor").mkdir_under_cursor, { + desc = "Create directory from text", + }) + map("n", "pg", require("utils.functions.git_paste").git_paste_prompt, { + desc = "Paste content from Git raw URL", + }) + + map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "Add workspace folder" }) + map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "Remove workspace folder" }) + map("n", "wl", function() + vim.print(vim.lsp.buf.list_workspace_folders()) + end, { desc = "List workspace folders" }) +end + +return M diff --git a/.config/nvim/lua/core/keymaps/groups.lua b/.config/nvim/lua/core/keymaps/groups.lua new file mode 100644 index 0000000..2b055aa --- /dev/null +++ b/.config/nvim/lua/core/keymaps/groups.lua @@ -0,0 +1,33 @@ +local M = {} + +function M.setup() + require("which-key").add({ + { "a", group = "AnyJump" }, + { "b", group = "Buffers" }, + { "c", group = "Code" }, + { "ca", group = "Code actions" }, + { "cc", group = "Calls" }, + { "cL", group = "LSP" }, + { "cP", group = "Python" }, + { "C", group = "CodeCompanion" }, + { "f", group = "Find" }, + { "g", group = "Git" }, + { "gd", group = "Diffview" }, + { "h", group = "Help" }, + { "i", group = "Image" }, + { "j", group = "AnyJump" }, + { "n", group = "Navigation and notifications" }, + { "N", group = "Noice" }, + { "o", group = "Open" }, + { "p", group = "Paste" }, + { "pg", group = "Paste Git raw" }, + { "s", group = "Search" }, + { "t", group = "Terminal" }, + { "T", group = "Telescope" }, + { "w", group = "Workspace" }, + { "x", group = "Executable bit" }, + { "y", group = "System clipboard" }, + }) +end + +return M diff --git a/.config/nvim/lua/core/keymaps/init.lua b/.config/nvim/lua/core/keymaps/init.lua new file mode 100644 index 0000000..dcb57aa --- /dev/null +++ b/.config/nvim/lua/core/keymaps/init.lua @@ -0,0 +1,4 @@ +require("core.keymaps.commands").setup() +require("core.keymaps.editing").setup() +require("core.keymaps.lsp").setup() +require("core.keymaps.groups").setup() diff --git a/.config/nvim/lua/core/keymaps/lsp.lua b/.config/nvim/lua/core/keymaps/lsp.lua new file mode 100644 index 0000000..9d7e58b --- /dev/null +++ b/.config/nvim/lua/core/keymaps/lsp.lua @@ -0,0 +1,47 @@ +local M = {} + +local map = vim.keymap.set + +function M.setup() + map("n", "gA", vim.lsp.buf.code_action, { desc = "Code action" }) + map("n", "gd", "Telescope lsp_definitions", { desc = "Definitions" }) + map("n", "gDc", "Telescope lsp_implementations", { desc = "Implementations" }) + map("n", "gDf", "Telescope lsp_definitions", { desc = "Definitions" }) + map("n", "gF", "edit ", { desc = "Edit file under cursor" }) + map("n", "gT", "Telescope lsp_type_definitions", { desc = "Type definitions" }) + map("n", "gb", "Gitsigns blame_line", { desc = "Blame line" }) + map("n", "gb", "Gitsigns blame", { desc = "Git blame" }) + map("n", "gi", "Telescope lsp_implementations", { desc = "Implementations" }) + map("n", "gj", "Telescope jumplist", { desc = "Jumplist" }) + map("n", "gr", "Telescope lsp_references", { desc = "References" }) + map("n", "gs", vim.lsp.buf.signature_help, { desc = "Signature help" }) + map("n", "ca", vim.lsp.buf.code_action, { desc = "Code action" }) + map("n", "ch", vim.lsp.buf.signature_help, { desc = "Signature help" }) + map("n", "cR", vim.lsp.buf.rename, { desc = "Rename" }) + map("n", "cr", "Telescope lsp_references", { desc = "References" }) + map("n", "cs", "Telescope lsp_document_symbols", { desc = "Document symbols" }) + map("n", "ct", "Telescope lsp_type_definitions", { desc = "Type definitions" }) + map("n", "cw", "Telescope lsp_dynamic_workspace_symbols", { desc = "Workspace symbols" }) + map("n", "ci", "Telescope lsp_implementations", { desc = "Implementations" }) + map("n", "cci", "Telescope lsp_incoming_calls", { desc = "Incoming calls" }) + map("n", "cco", "Telescope lsp_outgoing_calls", { desc = "Outgoing calls" }) + map("n", "cd", "Telescope diagnostics theme=dropdown layout_config={width=0.8}", { + desc = "Diagnostics", + }) + map("n", "cDs", "Telescope diagnostics theme=dropdown layout_config={width=0.8}", { + desc = "Diagnostics", + }) + map("n", "cDn", function() + vim.diagnostic.jump({ count = 1, float = true }) + end, { desc = "Next diagnostic" }) + map("n", "cDp", function() + vim.diagnostic.jump({ count = -1, float = true }) + end, { desc = "Previous diagnostic" }) + map("n", "cl", vim.diagnostic.setloclist, { desc = "Diagnostics to location list" }) + map("n", "Clr", "LspRestart", { desc = "Restart LSP" }) + map("n", "cPs", function() + vim.cmd("!pyright --createstub " .. vim.fn.expand("")) + end, { desc = "Generate Python stub" }) +end + +return M diff --git a/.config/nvim/lua/core/lazy.lua b/.config/nvim/lua/core/lazy.lua index 07bfc1e..4807946 100644 --- a/.config/nvim/lua/core/lazy.lua +++ b/.config/nvim/lua/core/lazy.lua @@ -1,60 +1,33 @@ -- 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 + 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("core.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 = { "habamax" } }, - -- automatically check for plugin updates checker = { enabled = true }, - dev = { - -- Directory where you store your local plugin projects. If a function is used, - -- the plugin directory (e.g. `~/projects/plugin-name`) must be returned. - ---@type string | fun(plugin: LazyPlugin): string - path = "~/.config/nvim/test", - ---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub - patterns = {}, -- For example {"folke"} - fallback = false, -- Fallback to git when local plugin doesn't exist - }, - -- lazy can generate helptags from the headings in markdown readme files, - -- so :help works even for plugins that don't have vim docs. - -- when the readme opens with :help it will be correctly displayed as markdown readme = { enabled = true, root = vim.fn.stdpath("state") .. "/lazy/readme", files = { "README.md", "lua/**/README.md" }, - -- only generate markdown helptags for plugins that don't have docs skip_if_doc_exists = true, }, - state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things - -- Enable profiling of lazy.nvim. This will add some overhead, - -- so only enable this when you are debugging lazy.nvim - profiling = { - -- Enables extra stats on the debug tab related to the loader cache. - -- Additionally gathers stats about all package.loaders - loader = false, - -- Track each new require in the Lazy profiling tab - require = false, - }, + state = vim.fn.stdpath("state") .. "/lazy/state.json", }) diff --git a/.config/nvim/lua/core/lsp-notifications.lua b/.config/nvim/lua/core/lsp-notifications.lua deleted file mode 100644 index 5add12e..0000000 --- a/.config/nvim/lua/core/lsp-notifications.lua +++ /dev/null @@ -1,107 +0,0 @@ --- Utility functions shared between progress reports for LSP and DAP -vim.notify = require("notify") - -local client_notifs = {} - -local function get_notif_data(client_id, token) - if not client_notifs[client_id] then - client_notifs[client_id] = {} - end - - if not client_notifs[client_id][token] then - client_notifs[client_id][token] = {} - end - - return client_notifs[client_id][token] -end - -local spinner_frames = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" } - -local function update_spinner(client_id, token, title) - local notif_data = get_notif_data(client_id, token) - - if notif_data.spinner then - local new_spinner = (notif_data.spinner + 1) % #spinner_frames - notif_data.spinner = new_spinner - - notif_data.notification = vim.notify("", nil, { - hide_from_history = true, - icon = spinner_frames[new_spinner], - replace = notif_data.notification, - title = title, - }) - - vim.defer_fn(function() - update_spinner(client_id, token, title) - end, 100) - end -end - -local function format_title(title, client_name) - return client_name .. (title and #title > 0 and ": " .. title or "") -end - -local function format_message(message, percentage) - return (percentage and percentage .. "%\t" or "") .. (message or "") -end - --- LSP integration --- Make sure to also have the snippet with the common helper functions in your config! - -vim.lsp.handlers["$/progress"] = function(_, result, ctx) - local client_id = ctx.client_id - - local val = result.value - - if not val.kind then - return - end - - local notif_data = get_notif_data(client_id, result.token) - - if val.kind == "begin" then - local message = format_message(val.message, val.percentage) - - notif_data.notification = vim.notify(message, "info", { - title = format_title("", vim.lsp.get_client_by_id(client_id).name), - icon = spinner_frames[1], - timeout = false, - hide_from_history = false, - }) - - notif_data.spinner = 1 - update_spinner(client_id, result.token, val.title) - elseif val.kind == "report" and notif_data then - notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", { - replace = notif_data.notification, - title = format_title("", vim.lsp.get_client_by_id(client_id).name), - hide_from_history = false, - }) - elseif val.kind == "end" and notif_data then - notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", { - icon = "", - replace = notif_data.notification, - title = format_title("", vim.lsp.get_client_by_id(client_id).name), - timeout = 3000, - }) - - notif_data.spinner = nil - end -end - -vim.lsp.handlers["window/showMessage"] = function(err, result, ctx) - local client = vim.lsp.get_client_by_id(ctx.client_id) - local lvl = ({ - "ERROR", - "WARN", - "INFO", - "DEBUG", - })[result.type] - vim.notify("LSP Message: " .. result.message, lvl, { - title = client.name, - timeout = 5000, - keep = function() - return lvl == "ERROR" or lvl == "WARN" - end, - }) -end diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua index 1fb0abf..6fe4cfc 100644 --- a/.config/nvim/lua/core/options.lua +++ b/.config/nvim/lua/core/options.lua @@ -1,7 +1,5 @@ local g = vim.g local o = vim.o -local A = vim.api -local l = vim.lsp g.mapleader = " " g.maplocalleader = "," @@ -11,14 +9,12 @@ o.showmode = false o.termguicolors = true o.background = "dark" o.mouse = "a" -o.syntax = "on" o.laststatus = 3 o.number = true o.relativenumber = true o.colorcolumn = "88" o.textwidth = 80 o.shiftwidth = 4 -o.expandtab = true o.tabstop = 4 o.autoindent = true o.ignorecase = true @@ -37,29 +33,19 @@ o.wildignore = ".git,.hg,.svn,CVS,.DS_Store,.idea,.vscode,.vscode-test,node_modu o.showmatch = true o.list = true o.listchars = "tab:»·,trail:·,nbsp:·,extends:>,precedes:<" -o.encoding = "utf-8" o.guifont = "JetBrainsMono Nerd Font 14" o.expandtab = true -o.hidden = true o.cmdheight = 1 o.updatetime = 300 o.timeoutlen = 500 o.pumwidth = 35 o.foldmethod = "marker" o.conceallevel = 1 -g.db_ui_use_nerd_fonts = 1 - --- vim.cmd.colorscheme = 'catppuccin-macchiato' -vim.cmd.colorscheme = "catppuccin" - --- set border for floating windows and signature help --- UNSUPPPORTED: https://github.com/neovim/neovim/issues/32242#issuecomment-2777120640 --- l.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) --- l.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) o.winborder = "rounded" vim.diagnostic.config({ virtual_text = false, + virtual_lines = { current_line = true }, signs = true, underline = true, severity_sort = true, diff --git a/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua b/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua deleted file mode 100644 index 3bc1814..0000000 --- a/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua +++ /dev/null @@ -1,137 +0,0 @@ -return { - "sontungexpt/better-diagnostic-virtual-text", - -- event = "LspAttach", - enabled = true, - config = function() - local diagnostic = require("better-diagnostic-virtual-text") - local vt = require("better-diagnostic-virtual-text.api") - local tbl_insert = table.insert - local strdisplaywidth = vim.fn.strdisplaywidth - local space = function(n) - return string.rep(" ", n) - end - - local SEVERITY_SUFFIXS = { - [vim.diagnostic.severity.ERROR] = "Error", - [vim.diagnostic.severity.WARN] = "Warn", - [vim.diagnostic.severity.INFO] = "Info", - [vim.diagnostic.severity.HINT] = "Hint", - } - - vt.format_line_chunks = function( - ui_opts, - line_idx, - line_msg, - severity, - max_line_length, - lasted_line, - virt_text_offset, - should_display_below, - above_instead, - removed_parts, - diagnostic - ) - local chunks = {} - local first_line = line_idx == 1 - local severity_suffix = SEVERITY_SUFFIXS[severity] - local msg = string.format("[%s]: %s", diagnostic.code, line_msg) - - local function hls(extend_hl_groups) - local default_groups = { - "DiagnosticVirtualText" .. severity_suffix, - "BetterDiagnosticVirtualText" .. severity_suffix, - } - if extend_hl_groups then - for i, hl in ipairs(extend_hl_groups) do - default_groups[2 + i] = hl - end - end - return default_groups - end - - local message_highlight = hls() - - if should_display_below then - local arrow_symbol = (above_instead and ui_opts.down_arrow or ui_opts.up_arrow):match("^%s*(.*)") - local space_offset = space(virt_text_offset) - if first_line then - if not removed_parts.arrow then - tbl_insert(chunks, { - space_offset .. arrow_symbol, - hls({ - "BetterDiagnosticVirtualTextArrow", - "BetterDiagnosticVirtualTextArrow" .. severity_suffix, - }), - }) - end - else - tbl_insert(chunks, { - space_offset .. space(strdisplaywidth(arrow_symbol)), - message_highlight, - }) - end - else - local arrow_symbol = ui_opts.arrow - if first_line then - if not removed_parts.arrow then - tbl_insert(chunks, { - arrow_symbol, - hls({ - "BetterDiagnosticVirtualTextArrow", - "BetterDiagnosticVirtualTextArrow" .. severity_suffix, - }), - }) - end - else - tbl_insert(chunks, { - space(virt_text_offset + strdisplaywidth(arrow_symbol)), - message_highlight, - }) - end - end - - if not removed_parts.left_kept_space then - local tree_symbol = " " - if first_line then - if not lasted_line then - tree_symbol = above_instead and " └ " or " ┌ " - end - elseif lasted_line then - tree_symbol = above_instead and " ┌ " or " └ " - else - tree_symbol = " │ " - end - tbl_insert(chunks, { - tree_symbol, - hls({ "BetterDiagnosticVirtualTextTree", "BetterDiagnosticVirtualTextTree" .. severity_suffix }), - }) - end - - tbl_insert(chunks, { - msg, - message_highlight, - }) - - if not removed_parts.right_kept_space then - local last_space = space(max_line_length - strdisplaywidth(msg) + ui_opts.right_kept_space) - tbl_insert(chunks, { last_space, message_highlight }) - end - - return chunks - end - - diagnostic.setup({ - ui = { - wrap_line_after = 150, -- wrap the line after this length to avoid the virtual text is too long - left_kept_space = 3, --- the number of spaces kept on the left side of the virtual text, make sure it enough to custom for each line - right_kept_space = 3, --- the number of spaces kept on the right side of the virtual text, make sure it enough to custom for each line - arrow = "  ", - up_arrow = "  ", - down_arrow = "  ", - above = false, -- the virtual text will be displayed above the line - }, - priority = 10000, -- the priority of virtual text - inline = true, - }) - end, -} diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua index 736f4d7..f58e5ce 100644 --- a/.config/nvim/lua/plugins/bufferline.lua +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -7,7 +7,7 @@ return { -- numbers = function(opts) -- return string.format("%s", opts.id) -- end, - numbers = function(opts) + numbers = function(_opts) return "" end, -- number_style = "superscript" | "subscript" | "" | { "none", "subscript" }, -- buffer_id at index 1, ordinal at index 2 @@ -45,7 +45,7 @@ return { -- diagnostics = false | "nvim_lsp" | "coc", diagnostics = "nvim_lsp", diagnostics_update_in_insert = false, - diagnostics_indicator = function(count, level, diagnostics_dict, context) + diagnostics_indicator = function(_count, _level, diagnostics_dict, _context) local s = " " for e, n in pairs(diagnostics_dict) do local sym = e == "error" and " " diff --git a/.config/nvim/lua/plugins/catppuccin.lua b/.config/nvim/lua/plugins/catppuccin.lua index cefabd7..b2ff23d 100644 --- a/.config/nvim/lua/plugins/catppuccin.lua +++ b/.config/nvim/lua/plugins/catppuccin.lua @@ -41,7 +41,6 @@ return { integrations = { cmp = true, gitsigns = true, - nvimtree = true, mini = { enabled = true, indentscope_color = "", @@ -51,11 +50,7 @@ return { diffview = true, fidget = true, noice = true, - indent_blankline = { - enabled = true, - scope_color = "lavendar", -- catppuccin color (eg. `lavender`) Default: text - colored_indent_levels = true, - }, + snacks = true, copilot_vim = true, native_lsp = { enabled = true, @@ -77,7 +72,6 @@ return { background = true, }, }, - notify = true, treesitter = true, rainbow_delimiters = true, render_markdown = true, diff --git a/.config/nvim/lua/plugins/codecompanion.lua b/.config/nvim/lua/plugins/codecompanion.lua index b03298f..76aeb51 100644 --- a/.config/nvim/lua/plugins/codecompanion.lua +++ b/.config/nvim/lua/plugins/codecompanion.lua @@ -6,6 +6,42 @@ return { "j-hui/fidget.nvim", "ravitemer/mcphub.nvim", }, + keys = { + { + "Cf", + function() + require("codecompanion").chat({ window_opts = { height = 1, layout = "buffer" } }) + end, + desc = "Fullscreen chat", + }, + { + "Ch", + function() + require("codecompanion").chat({ + window_opts = { height = 0.24, layout = "horizontal", position = "bottom" }, + }) + end, + desc = "Horizontal chat", + }, + { "Cc", "CodeCompanionChat Toggle", desc = "Toggle chat" }, + { "oc", "CodeCompanionChat Toggle", desc = "Toggle chat" }, + { + "Ci", + function() + vim.api.nvim_feedkeys(":CodeCompanion #{buffer} ", "n", false) + end, + mode = { "n", "v" }, + desc = "Inline prompt", + silent = false, + }, + { "Ct", "CodeCompanionChat Toggle", desc = "Toggle chat" }, + { "CA", "CodeCompanionActions", desc = "Actions" }, + { "Ca", "CodeCompanionChat Add", mode = "v", desc = "Add selection to chat" }, + { "Ce", "CodeCompanion /explain", mode = "v", desc = "Explain selection" }, + { "Cf", "CodeCompanion /fix", mode = "v", desc = "Fix selection" }, + { "Cl", "CodeCompanion /lsp", mode = "v", desc = "Explain LSP diagnostics" }, + { "Ct", "CodeCompanion /tests", mode = "v", desc = "Generate tests" }, + }, opts = { adapters = { -- {{{ HTTP @@ -177,7 +213,7 @@ return { ---@param adapter CodeCompanion.Adapter ---@param context table ---@return string - prompt_decorator = function(message, adapter, context) + prompt_decorator = function(message, _adapter, _context) return string.format([[%s]], message) end, completion_provider = "cmp", @@ -202,7 +238,7 @@ return { action_palette = { provider = "telescope", width = 75, - heigth = 45, + height = 45, }, chat = { layout = "vertical", @@ -291,7 +327,7 @@ return { ---@param tokens number ---@param adapter CodeCompanion.Adapter ---@return string - token_count = function(tokens, adapter) + token_count = function(tokens, _adapter) return " (" .. tokens .. " tokens)" end, }, @@ -343,7 +379,7 @@ return { }, }, init = function() - require("utils.codecompanion.fidget-spinner"):init() + require("utils.codecompanion.fidget-spinner").init() require("utils.codecompanion.extmarks").setup() end, } diff --git a/.config/nvim/lua/plugins/conform.lua b/.config/nvim/lua/plugins/conform.lua index 24e7a53..1e3bae2 100644 --- a/.config/nvim/lua/plugins/conform.lua +++ b/.config/nvim/lua/plugins/conform.lua @@ -1,18 +1,13 @@ return { "stevearc/conform.nvim", opts = { - on_init = function(client) - require("conform").formatters.shfmt = { - append_args = { "-i", "0", "-ci", "-sr" }, - } - end, formatters_by_ft = { python = function(bufnr) if require("conform").get_formatter_info("ruff_format", bufnr).available then return { "ruff_fix", - "ruff_format", "ruff_organize_imports", + "ruff_format", } else return { "isort", "black" } @@ -25,14 +20,17 @@ return { javascriptreact = { "prettier" }, typescript = { "prettier" }, typescriptreact = { "prettier" }, - md = { "markdownlint" }, - ["*"] = { "codespell" }, + markdown = { "markdownlint" }, ["_"] = { "trim_whitespace" }, }, + formatters = { + shfmt = { + append_args = { "-i", "0", "-ci", "-sr" }, + }, + }, format_on_save = { - -- These options will be passed to conform.format() timeout_ms = 500, - -- lsp_format = "fallback", + lsp_format = "never", }, }, } diff --git a/.config/nvim/lua/plugins/copilot-lualine.lua b/.config/nvim/lua/plugins/copilot-lualine.lua deleted file mode 100644 index 44de183..0000000 --- a/.config/nvim/lua/plugins/copilot-lualine.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'AndreM222/copilot-lualine' -} diff --git a/.config/nvim/lua/plugins/copilot.lua b/.config/nvim/lua/plugins/copilot.lua index 7d9393b..397e905 100644 --- a/.config/nvim/lua/plugins/copilot.lua +++ b/.config/nvim/lua/plugins/copilot.lua @@ -2,6 +2,9 @@ return { "zbirenbaum/copilot.lua", cmd = "Copilot", event = "InsertEnter", + keys = { + { "cp", "vertical Copilot panel", desc = "Copilot panel" }, + }, opts = { panel = { enabled = true, diff --git a/.config/nvim/lua/plugins/diffview.lua b/.config/nvim/lua/plugins/diffview.lua index 8046cc3..e4c0f7c 100644 --- a/.config/nvim/lua/plugins/diffview.lua +++ b/.config/nvim/lua/plugins/diffview.lua @@ -1,6 +1,14 @@ return { "sindrets/diffview.nvim", dependencies = "nvim-tree/nvim-web-devicons", + keys = { + { "gdc", "DiffviewClose", desc = "Close Diffview" }, + { "gdf", "DiffviewFileHistory %", desc = "File history" }, + { "gdh", "DiffviewHistory", desc = "Repository history" }, + { "gdo", "DiffviewOpen", desc = "Open Diffview" }, + { "gdr", "DiffviewRefresh", desc = "Refresh Diffview" }, + { "gdt", "DiffviewToggleFiles", desc = "Toggle files" }, + }, opts = { view = { -- Disable the default normal mode mapping for ``: @@ -8,20 +16,19 @@ return { -- Disable the default visual mode mapping for `gf`: -- { "x", "gf", false }, }, - }, - hooks = { - diff_buf_read = function(bufnr) - -- Change local options in diff buffers - vim.opt_local.wrap = false - vim.opt_local.list = false - vim.opt_local.colorcolumn = { 80 } - end, - view_opened = function(view) - require("notify").notify( - ("A new %s was opened on tab page %d!"):format(view.class:name(), view.tabpage), - "info", - { timeout = 5000, title = "Diffview" } - ) - end, + hooks = { + diff_buf_read = function() + vim.opt_local.wrap = false + vim.opt_local.list = false + vim.opt_local.colorcolumn = { 80 } + end, + view_opened = function(view) + vim.notify( + ("A new %s was opened on tab page %d!"):format(view.class:name(), view.tabpage), + vim.log.levels.INFO, + { timeout = 5000, title = "Diffview" } + ) + end, + }, }, } diff --git a/.config/nvim/lua/plugins/telescope-glyph.lua b/.config/nvim/lua/plugins/editing.lua similarity index 100% rename from .config/nvim/lua/plugins/telescope-glyph.lua rename to .config/nvim/lua/plugins/editing.lua diff --git a/.config/nvim/lua/plugins/fidget.lua b/.config/nvim/lua/plugins/fidget.lua index 822cd12..fd81778 100644 --- a/.config/nvim/lua/plugins/fidget.lua +++ b/.config/nvim/lua/plugins/fidget.lua @@ -42,8 +42,6 @@ return { icon_style = "Question", -- Highlight group for group icons priority = 30, -- Ordering priority for LSP notification group skip_history = true, -- Whether progress notifications should be omitted from history - -- How to format a progress message - format_message = require("fidget.progress.display").default_format_message, -- How to format a progress annotation format_annote = function(msg) return msg.title @@ -71,15 +69,6 @@ return { filter = vim.log.levels.INFO, -- Minimum notifications level history_size = 128, -- Number of removed messages to retain in history override_vim_notify = false, -- Automatically override vim.notify() with Fidget - -- How to configure notification groups when instantiated - configs = { default = require("fidget.notification").default_config }, - -- Conditionally redirect notifications to another backend - redirect = function(msg, level, opts) - if opts and opts.on_open then - return require("fidget.integration.nvim-notify").delegate(msg, level, opts) - end - end, - -- Options related to how notifications are rendered as text view = { stack_upwards = true, -- Display notification items from bottom to top @@ -87,14 +76,6 @@ return { group_separator = "---", -- Separator between notification groups }, }, - integration = { - ["nvim-tree"] = { - enable = true, -- Integrate with nvim-tree/nvim-tree.lua (if installed) - }, - ["xcodebuild-nvim"] = { - enable = false, -- Integrate with wojciech-kulik/xcodebuild.nvim (if installed) - }, - }, -- Options related to logging logger = { level = vim.log.levels.WARN, -- Minimum logging level diff --git a/.config/nvim/lua/plugins/goto-preview.lua b/.config/nvim/lua/plugins/goto-preview.lua index 81a3c24..f0b69cf 100644 --- a/.config/nvim/lua/plugins/goto-preview.lua +++ b/.config/nvim/lua/plugins/goto-preview.lua @@ -1 +1,26 @@ -return { "rmagatti/goto-preview" } +return { + "rmagatti/goto-preview", + keys = { + { + "gpc", + function() + require("goto-preview").close_all_win() + end, + desc = "Close preview windows", + }, + { + "gpd", + function() + require("goto-preview").goto_preview_definition() + end, + desc = "Preview definition", + }, + { + "gpi", + function() + require("goto-preview").goto_preview_implementation() + end, + desc = "Preview implementation", + }, + }, +} diff --git a/.config/nvim/lua/plugins/image.lua b/.config/nvim/lua/plugins/image.lua index 88941c5..e692010 100644 --- a/.config/nvim/lua/plugins/image.lua +++ b/.config/nvim/lua/plugins/image.lua @@ -1,5 +1,21 @@ return { "3rd/image.nvim", + keys = { + { + "id", + function() + require("image").disable() + end, + desc = "Disable image rendering", + }, + { + "ie", + function() + require("image").enable() + end, + desc = "Enable image rendering", + }, + }, opts = { backend = "kitty", -- processor = "magick_rock", -- or "magick_cli" diff --git a/.config/nvim/lua/plugins/img-clip.lua b/.config/nvim/lua/plugins/img-clip.lua index bb94c14..32cf98c 100644 --- a/.config/nvim/lua/plugins/img-clip.lua +++ b/.config/nvim/lua/plugins/img-clip.lua @@ -1,6 +1,30 @@ +local function find_and_paste_image() + local builtin = require("telescope.builtin") + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + + builtin.find_files({ + attach_mappings = function(_, map) + local function paste_image(prompt_bufnr) + local entry = action_state.get_selected_entry() + actions.close(prompt_bufnr) + require("img-clip").paste_image(nil, entry.path or entry[1]) + end + + map("i", "", paste_image) + map("n", "", paste_image) + return true + end, + }) +end + return { "HakonHarnes/img-clip.nvim", event = "VeryLazy", + keys = { + { "pi", find_and_paste_image, desc = "Find and paste image" }, + { "Ti", find_and_paste_image, desc = "Find and paste image" }, + }, opts = { default = { -- file and directory options diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 331345e..672f4bf 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -1,7 +1,7 @@ return { "neovim/nvim-lspconfig", + dependencies = { "hrsh7th/cmp-nvim-lsp" }, config = function() - vim.notify = require("notify") local servers = { "bashls", "basedpyright", @@ -13,113 +13,63 @@ return { "html", "cssls", "lua_ls", - "eslint", - -- "ts_ls", "vtsls", "ansiblels", "docker_compose_language_service", "docker_language_server", - "golangci_lint_ls", "gopls", - "ruff", } local capabilities = require("cmp_nvim_lsp").default_capabilities() - for _, lsp in ipairs(servers) do - if lsp == "lua_ls" then - vim.lsp.config("lua_ls", { - capabilities = capabilities, - on_init = function(client) - if client.workspace_folders then - local path = client.workspace_folders[1].name - if - path ~= vim.fn.stdpath("config") - and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) - then - return - end - end + vim.lsp.config("*", { capabilities = capabilities }) - client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { - runtime = { - -- Tell the language server which version of Lua you're using - -- (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - }, - -- Make the server aware of Neovim runtime files - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME, - -- Depending on the usage, you might want to add additional paths here. - -- "${3rd}/luv/library", - -- "${3rd}/busted/library", - "/usr/lib/lua-language-server/meta/3rd/busted/library", - }, - -- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189) - -- library = vim.api.nvim_get_runtime_file("", true) - }, - }) - end, - settings = { - Lua = {}, + vim.lsp.config("lua_ls", { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if + path ~= vim.fn.stdpath("config") + and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) + then + return + end + end + + client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { + runtime = { + version = "LuaJIT", + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + "/usr/lib/lua-language-server/meta/3rd/busted/library", + }, }, - handlers = {}, - root_dir = function(bufnr, on_dir) - if not vim.fn.bufname(bufnr):match("%.txt$") then - on_dir(vim.fn.getcwd()) - end - end, }) - elseif lsp == "basedpyright" then - vim.lsp.config(lsp, { - capabilities = capabilities, - settings = { - basedpyright = { - analysis = { - autoSearchPaths = true, - diagnosticMode = "openFilesOnly", - useLibraryCodeForTypes = true, - autoFormatStrings = true, - }, - diagnosticMode = "openFilesOnly", - inlayHints = { - callArgumentNames = true, - }, - allowedUntypedLibraries = true, + end, + settings = { Lua = {} }, + }) + + vim.lsp.config("basedpyright", { + settings = { + basedpyright = { + analysis = { + autoSearchPaths = true, + diagnosticMode = "openFilesOnly", + autoFormatStrings = true, + inlayHints = { + callArgumentNames = true, + }, + diagnosticSeverityOverrides = { reportMissingTypeStubs = true, reportImportCycles = true, reportUnusedImport = true, }, - python = { - analysis = { - ignore = { "*" }, - }, - }, }, - }) - elseif lsp == "ruff" then - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }), - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client == nil then - return - end - if client.name == "ruff" then - -- Disable hover in favor of Pyright - client.server_capabilities.hoverProvider = false - end - end, - desc = "LSP: Disable hover capability from Ruff", - }) - vim.lsp.config(lsp, { - settings = { - configuration = vim.fn.stdpath("config") .. "/lua/utils/ruff.toml", - logLevel = "info", - }, - }) - end - vim.lsp.enable(lsp) - end + }, + }, + }) + + vim.lsp.enable(servers) end, } diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 6af0173..448b6c1 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,90 +1,80 @@ -return { - "nvim-lualine/lualine.nvim", - config = function() - require("lualine").setup({ - options = { - icons_enabled = true, - theme = "catppuccin", - -- theme = 'dracula', - -- theme = 'horizon', - -- theme = 'onedark', - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = {}, - always_divide_middle = true, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "branch", "diff" }, - lualine_c = { "filename" }, - lualine_x = { - { - "seachcount", - { require("mcphub.extensions.lualine") }, - "copilot", - symbols = { - status = { - icons = { - enabled = " ", - sleep = " ", -- auto-trigger disabled - disabled = " ", - warning = " ", - unknown = " ", - }, - hl = { - enabled = "#50FA7B", - sleep = "#AEB7D0", - disabled = "#6272A4", - warning = "#FFB86C", - unknown = "#FF5555", - }, - }, - spinners = "dots", -- has some premade spinners - spinner_color = "#6272A4", - }, - show_colors = true, - show_loading = true, - }, - { - "diagnostics", - "fileformat", - symbols = { - unix = "", -- e712 - dos = "", -- e70f - mac = "", -- e711 - }, - }, - "encoding", - "fileformat", - { "filetype", colored = true, icon_only = false }, - }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { - { - "filename", - file_status = true, -- Displays file status (readonly status, modified status) - path = 0, -- 0: Just the filename - shorting_target = 40, -- Shortens path to leave 40 spaces in the window - symbols = { - modified = "[+]", -- Text to show when the file is modified. - readonly = "[-]", -- Text to show when the file is non-modifiable or readonly. - unnamed = "[No Name]", -- Text to show for unnamed buffers. - }, - }, - M, - }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - extensions = { "quickfix", "fzf", "nvim-tree", "symbols-outline", "fugitive", "toggleterm", "man" }, - }) - end, - depends = { "kyazdani42/nvim-web-devicons" }, -} +return { + "nvim-lualine/lualine.nvim", + dependencies = { + "AndreM222/copilot-lualine", + "nvim-tree/nvim-web-devicons", + "ravitemer/mcphub.nvim", + }, + config = function() + require("lualine").setup({ + options = { + theme = "catppuccin", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff" }, + lualine_c = { "filename" }, + lualine_x = { + "searchcount", + require("mcphub.extensions.lualine"), + { + "copilot", + symbols = { + status = { + icons = { + disabled = " ", + enabled = " ", + sleep = " ", + unknown = " ", + warning = " ", + }, + hl = { + disabled = "#6272A4", + enabled = "#50FA7B", + sleep = "#AEB7D0", + unknown = "#FF5555", + warning = "#FFB86C", + }, + }, + spinners = "dots", + spinner_color = "#6272A4", + }, + show_colors = true, + show_loading = true, + }, + "diagnostics", + "encoding", + { + "fileformat", + symbols = { dos = "", mac = "", unix = "" }, + }, + { "filetype", colored = true }, + }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + "filename", + file_status = true, + path = 0, + symbols = { + modified = "[+]", + readonly = "[-]", + unnamed = "[No Name]", + }, + }, + }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + extensions = { "man", "quickfix", "toggleterm" }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua index 362c3ae..7c2e8d3 100644 --- a/.config/nvim/lua/plugins/mini.lua +++ b/.config/nvim/lua/plugins/mini.lua @@ -1,6 +1,5 @@ return { "echasnovski/mini.diff", - depends = { "echasnovski/mini.nvim" }, config = function() local diff = require("mini.diff") diff.setup({ diff --git a/.config/nvim/lua/plugins/noice.lua b/.config/nvim/lua/plugins/noice.lua index c52497f..a671809 100644 --- a/.config/nvim/lua/plugins/noice.lua +++ b/.config/nvim/lua/plugins/noice.lua @@ -1,10 +1,17 @@ return { "folke/noice.nvim", event = "VeryLazy", + keys = { + { "Nd", "Noice dismiss", desc = "Dismiss messages" }, + { "Ne", "Noice errors", desc = "Errors" }, + { "Nh", "Noice telescope", desc = "Message history" }, + { "Nl", "Noice last", desc = "Last message" }, + { "Ns", "Noice stats", desc = "Statistics" }, + }, opts = { lsp = { progress = { - enabled = true, + enabled = false, -- Lsp Progress is formatted using the builtins for lsp_progress. See config.format.builtin -- See the section on formatting for more details on how to customize. --- @type NoiceFormat|string @@ -99,10 +106,9 @@ return { -- Noice can be used as `vim.notify` so you can route any notification like other messages -- Notification messages have their level and other properties set. -- event is always "notify" and kind can be any log level as a string - -- The default routes will forward notifications to nvim-notify + -- Keep command and message history available through Noice. -- Benefit of using Noice for this is the routing and consistent history view - enabled = true, - view = "notify", + enabled = false, }, documentation = { view = "hover", @@ -118,7 +124,9 @@ return { markdown = { hover = { ["|(%S-)|"] = vim.cmd.help, -- vim help links - ["%[.-%]%((%S-)%)"] = require("noice.util").open, -- markdown links + ["%[.-%]%((%S-)%)"] = function(url) + require("noice.util").open(url) + end, -- markdown links }, highlights = { ["|%S-|"] = "@text.reference", @@ -131,11 +139,6 @@ return { }, }, dependencies = { - -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries "MunifTanjim/nui.nvim", - -- OPTIONAL: - -- `nvim-notify` is only needed, if you want to use the notification view. - -- If not available, we use `mini` as the fallback - "rcarriga/nvim-notify", }, } diff --git a/.config/nvim/lua/plugins/none-ls.lua b/.config/nvim/lua/plugins/none-ls.lua deleted file mode 100644 index 74038c5..0000000 --- a/.config/nvim/lua/plugins/none-ls.lua +++ /dev/null @@ -1,75 +0,0 @@ -return { - "nvimtools/none-ls.nvim", - config = function() - local null_ls = require("null-ls") - local helpers = require("null-ls.helpers") - -- syncronous formatting - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - - local sources = { - null_ls.builtins.completion.luasnip, - -- null_ls.builtins.diagnostics.mypy, - null_ls.builtins.diagnostics.pydoclint, - null_ls.builtins.diagnostics.markdownlint, - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.isort, - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.markdownlint, - null_ls.builtins.formatting.prettier, -- handled by lsp server - null_ls.builtins.formatting.shfmt.with({ - filetypes = { "sh", "bash" }, - extra_args = { "-i", "0", "-ci", "-sr" }, - }), - null_ls.builtins.formatting.gofmt, - null_ls.builtins.formatting.goimports, - null_ls.builtins.formatting.goimports_reviser, - null_ls.builtins.hover.printenv, - } - - require("null-ls").setup({ - border = "rounded", - cmd = { "nvim" }, - debounce = 250, - debug = false, - default_timeout = 5000, - diagnostic_config = { - virtual_text = false, - signs = true, - underline = true, - float = { border = "rounded", source = true }, - severity_sort = true, - }, - -- diagnostics_format = "#{m}", - diagnostics_format = "[#{c}] #{m} (#{s})", - fallback_severity = vim.diagnostic.severity.ERROR, - log_level = "warn", - notify_format = "[null-ls] %s", - on_init = nil, - on_exit = nil, - root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git"), - root_dir_async = nil, - should_attach = nil, - sources = sources, - temp_dir = nil, - update_in_insert = false, - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ - async = false, - bufnr = bufnr, - filter = function(client) - return client.name == "null-ls" - end, - }) - end, - }) - end - end, - }) - end, -} diff --git a/.config/nvim/lua/plugins/notify.lua b/.config/nvim/lua/plugins/notify.lua deleted file mode 100644 index f40ecc8..0000000 --- a/.config/nvim/lua/plugins/notify.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "rcarriga/nvim-notify", - opts = { - background_colour = "#000000", - fps = 144, - icons = { - DEBUG = "", - ERROR = "", - INFO = "", - TRACE = "✎", - WARN = "", - }, - level = 2, - minimum_width = 50, - render = "default", - stages = "fade_in_slide_out", - timeout = 3000, - top_down = true, - }, -} diff --git a/.config/nvim/lua/plugins/nvim-autopairs.lua b/.config/nvim/lua/plugins/nvim-autopairs.lua index c80fd3d..4691c1e 100644 --- a/.config/nvim/lua/plugins/nvim-autopairs.lua +++ b/.config/nvim/lua/plugins/nvim-autopairs.lua @@ -3,7 +3,7 @@ return { event = "InsertEnter", config = true, opts = { - enabled = function(bufnr) + enabled = function(_bufnr) return true end, disable_filetype = { "TelescopePrompt", "spectre_panel" }, diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua index 5467692..127d746 100644 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -22,7 +22,7 @@ return { local cmp_autopairs = require("nvim-autopairs.completion.cmp") local has_words_before = function() - if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then + if vim.api.nvim_get_option_value("buftype", { buf = 0 }) == "prompt" then return false end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -43,7 +43,7 @@ return { cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = "path" } }, { + sources = cmp.config.sources({ { name = "async_path" } }, { { name = "cmdline", option = { ignore_cmds = { "Man", "!" } } }, }), matching = { disallow_symbol_nonprefix_matching = false }, @@ -51,7 +51,7 @@ return { cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - require("cmp").setup({ + cmp.setup({ snippet = { expand = function(args) -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. @@ -180,7 +180,7 @@ return { { name = "render-markdown", group_index = 2 }, { name = "html-css", - group_indx = 2, + group_index = 2, option = { enable_on = { "html", "jsx", "tsx", "typescript", "typescriptreact" }, -- html is enabled by default notify = false, diff --git a/.config/nvim/lua/plugins/nvim-lint.lua b/.config/nvim/lua/plugins/nvim-lint.lua index bff311f..bd96450 100644 --- a/.config/nvim/lua/plugins/nvim-lint.lua +++ b/.config/nvim/lua/plugins/nvim-lint.lua @@ -1,39 +1,53 @@ return { "mfussenegger/nvim-lint", + event = { "BufNewFile", "BufReadPre" }, config = function() local lint = require("lint") + local parser = require("lint.parser") + + lint.linters.pydoclint = { + cmd = "pydoclint", + args = { "--show-filenames-in-every-violation-message=true", "-q" }, + stdin = false, + stream = "stderr", + ignore_exitcode = true, + parser = parser.from_pattern("(.+):(%d+): (DOC%d+): (.+)", { "file", "lnum", "code", "message" }, nil, { + severity = vim.diagnostic.severity.WARN, + source = "pydoclint", + }), + } + local python_linters = { "ruff" } + if vim.fn.executable("pydoclint") == 1 then + table.insert(python_linters, "pydoclint") + end + lint.linters_by_ft = { - markdown = { "markdownlint" }, - lua = { "luacheck" }, - python = { "ruff" }, - sh = { "shellcheck" }, - json = { "jsonlint" }, - yaml = { "yamllint" }, - vim = { "vint" }, go = { "golangcilint" }, + json = { "jsonlint" }, + lua = { "luacheck" }, + markdown = { "markdownlint" }, + python = python_linters, + sh = { "shellcheck" }, typescript = { "eslint" }, typescriptreact = { "eslint" }, + vim = { "vint" }, + yaml = { "yamllint" }, } - lint.linters.jsonlint.cmd = "vscode-json-language-server" - lint.linters.shellcheck.args = { - "-s", - "bash", - "-o", - "all", - "-e", - "2250", - } - -- Save original function - local orig_try_lint = lint.try_lint - lint.try_lint = function(...) - local opts = select(2, ...) - local bufnr = (type(opts) == "table" and opts.bufnr) or vim.api.nvim_get_current_buf() - if vim.api.nvim_get_option_value("buftype", { buf = bufnr }) ~= "" then - return - end - return orig_try_lint(...) - end + lint.linters.shellcheck.args = { "-s", "bash", "-o", "all", "-e", "2250" } + + local lint_group = vim.api.nvim_create_augroup("LintOnSave", { clear = true }) + vim.api.nvim_create_autocmd("BufWritePost", { + group = lint_group, + callback = function(args) + if vim.bo[args.buf].buftype ~= "" then + return + end + lint.try_lint(nil, { bufnr = args.buf }) + if vim.fn.executable("codespell") == 1 then + lint.try_lint("codespell", { bufnr = args.buf }) + end + end, + }) end, - event = { "BufReadPre", "BufNewFile" }, } diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua deleted file mode 100644 index ec6fb2f..0000000 --- a/.config/nvim/lua/plugins/nvim-tree.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "nvim-tree/nvim-tree.lua", - version = "*", - lazy = false, - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - config = function() - require("nvim-tree").setup({}) - end, -} diff --git a/.config/nvim/lua/plugins/snacks.lua b/.config/nvim/lua/plugins/snacks.lua index 16adf0b..a222d54 100644 --- a/.config/nvim/lua/plugins/snacks.lua +++ b/.config/nvim/lua/plugins/snacks.lua @@ -2,6 +2,68 @@ return { "folke/snacks.nvim", priority = 1000, lazy = false, + keys = { + { + "fb", + function() + Snacks.explorer() + end, + desc = "File browser", + }, + { + "gg", + function() + Snacks.lazygit() + end, + desc = "Lazygit", + }, + { + "nc", + function() + Snacks.notifier.hide() + end, + desc = "Dismiss notifications", + }, + { + "nh", + function() + Snacks.notifier.show_history() + end, + desc = "Notification history", + }, + { + "nt", + function() + Snacks.explorer() + end, + desc = "File explorer", + }, + { + "sn", + function() + Snacks.win({ + file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1], + width = 0.6, + height = 0.6, + wo = { + spell = false, + wrap = false, + signcolumn = "yes", + statuscolumn = " ", + conceallevel = 3, + }, + }) + end, + desc = "Neovim news", + }, + { + "Tn", + function() + Snacks.notifier.show_history() + end, + desc = "Notifications", + }, + }, ---@type snacks.Config opts = { -- your configuration comes here @@ -73,7 +135,7 @@ return { debug = "  ", trace = "  ", }, - keep = function(notif) + keep = function() return vim.fn.getcmdpos() > 0 end, ---@type snacks.notifier.style @@ -92,43 +154,7 @@ return { scroll = { enabled = false }, statuscolumn = { enabled = false }, words = { enabled = false }, - terminal = { - enabled = true, - bo = { - filetype = "snacks_terminal", - }, - wo = {}, - keys = { - q = "hide", - gf = function(self) - local f = vim.fn.findfile(vim.fn.expand(""), "**") - if f == "" then - Snacks.notify.warn("No file under cursor") - else - self:hide() - vim.schedule(function() - vim.cmd("e " .. f) - end) - end - end, - term_normal = { - "", - function(self) - self.esc_timer = self.esc_timer or (vim.uv or vim.loop).new_timer() - if self.esc_timer:is_active() then - self.esc_timer:stop() - vim.cmd("stopinsert") - else - self.esc_timer:start(200, 0, function() end) - return "" - end - end, - mode = "t", - expr = true, - desc = "Double escape to normal mode", - }, - }, - }, + terminal = { enabled = false }, win = { enabled = true }, styles = { input = { diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index b87332f..9612e87 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -2,9 +2,7 @@ return { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim", - -- "jonarrien/telescope-cmdline.nvim", "nat-418/telescope-color-names.nvim", - "nvim-telescope/telescope-file-browser.nvim", "ghassan0/telescope-glyph.nvim", "nvim-telescope/telescope-ui-select.nvim", { @@ -13,6 +11,64 @@ return { }, "folke/noice.nvim", }, + cmd = "Telescope", + keys = { + { "//", "Telescope current_buffer_fuzzy_find previewer=false", desc = "Find in current buffer" }, + { + "??", + "Telescope lsp_document_symbols theme=dropdown layout_config={width=0.5}", + desc = "Document symbols", + }, + { "bb", "Telescope buffers", desc = "Buffers" }, + { + "fc", + 'Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical', + desc = "Color names", + }, + { + "ff", + "Telescope find_files find_command=rg,--ignore,--follow,--hidden,--files prompt_prefix=🔍", + desc = "Find files", + }, + { "fg", "Telescope live_grep", desc = "Live grep" }, + { + "fG", + 'Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical', + desc = "Glyphs", + }, + { "fr", "Telescope oldfiles theme=dropdown layout_config={width=0.5}", desc = "Recent files" }, + { "gc", "Telescope git_commits", desc = "Git commits" }, + { "gf", "Telescope git_files", desc = "Git files" }, + { "hc", "Telescope commands", desc = "Commands" }, + { "hk", "Telescope keymaps", desc = "Keymaps" }, + { "hm", "Telescope man_pages theme=dropdown layout_config={width=0.75}", desc = "Man pages" }, + { "hs", "Telescope spell_suggest", desc = "Spelling suggestions" }, + { "ht", "Telescope help_tags", desc = "Help tags" }, + { "hv", "Telescope vim_options", desc = "Neovim options" }, + { "s/", "Telescope search_history", desc = "Search history" }, + { "sF", "Telescope fidget", desc = "Fidget history" }, + { + "sf", + "Telescope find_files find_command=rg,--ignore,--follow,--hidden,--files prompt_prefix=🔍", + desc = "Search files", + }, + { "sg", "Telescope live_grep", desc = "Live grep" }, + { "sh", "Telescope command_history", desc = "Command history" }, + { "sm", "Telescope man_pages", desc = "Man pages" }, + { "Tc", "Telescope colorscheme", desc = "Colorschemes" }, + { + "TC", + 'Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical', + desc = "Color names", + }, + { + "Tg", + 'Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical', + desc = "Glyphs", + }, + { "TN", "Telescope noice theme=dropdown layout_config={width=0.75}", desc = "Noice history" }, + { "Tr", "Telescope reloader", desc = "Reload Lua module" }, + }, opts = { defaults = { -- Default configuration for telescope goes here: @@ -95,19 +151,6 @@ return { enabled = true, }, }, - file_browser = { - theme = "ivy", - -- disables netrw and use telescope-file-browser in its place - hijack_netrw = true, - mappings = { - ["i"] = { - -- your custom insert mode mappings - }, - ["n"] = { - -- your custom normal mode mappings - }, - }, - }, -- ["ui-select"] = { -- require("telescope.themes").get_dropdown({ -- winblend = 10, @@ -119,4 +162,24 @@ return { -- }, }, }, + config = function(_, opts) + local telescope = require("telescope") + local actions = require("telescope.actions") + local config = require("telescope.config") + local vimgrep_arguments = vim.deepcopy(config.values.vimgrep_arguments) + vim.list_extend(vimgrep_arguments, { "--hidden", "--glob", "!**/.git/*" }) + + opts.defaults.vimgrep_arguments = vimgrep_arguments + opts.defaults.mappings = vim.tbl_deep_extend("force", opts.defaults.mappings or {}, { + i = { + [""] = actions.results_scrolling_left, + [""] = actions.results_scrolling_right, + }, + }) + telescope.setup(opts) + + for _, extension in ipairs({ "color_names", "fzf", "glyph", "noice", "ui-select" }) do + pcall(telescope.load_extension, extension) + end + end, } diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua index 3a9d989..1473e3e 100644 --- a/.config/nvim/lua/plugins/toggleterm.lua +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -1,6 +1,52 @@ +local terminals = {} + +local function toggle(name) + return function() + terminals[name]:toggle() + end +end + return { "akinsho/toggleterm.nvim", version = "*", + keys = { + { "", "ToggleTerm name=toggleterm", desc = "Toggle terminal" }, + { "-", "ToggleTerm direction=horizontal", desc = "Toggle horizontal terminal" }, + { "|", "ToggleTerm direction=vertical", desc = "Toggle vertical terminal" }, + { "ob", toggle("btop"), desc = "Open btop" }, + { "od", toggle("lazydocker"), desc = "Open Lazydocker" }, + { + "oh", + "ToggleTerm direction=horizontal name=toggleterm-hori", + desc = "Open horizontal terminal", + }, + { "oi", toggle("iotop"), desc = "Open iotop" }, + { "on", toggle("rmpc"), desc = "Open rmpc" }, + { "oN", toggle("nvtop"), desc = "Open nvtop" }, + { "op", toggle("ipython"), desc = "Open IPython" }, + { "oP", toggle("ipython-full"), desc = "Open full IPython" }, + { "ot", "ToggleTerm name=toggleterm", desc = "Open terminal" }, + { "oT", "ToggleTerm name=toggleterm-full direction=tab", desc = "Open full terminal" }, + { + "ov", + "ToggleTerm direction=vertical name=toggleterm-vert", + desc = "Open vertical terminal", + }, + { "tf", "ToggleTerm name=toggleterm", desc = "Toggle terminal" }, + { + "th", + "ToggleTerm direction=horizontal name=toggleterm-hori", + desc = "Toggle horizontal terminal", + }, + { "ts", "TermSelect", desc = "Select terminal" }, + { "tt", "ToggleTerm name=toggleterm", desc = "Toggle terminal" }, + { "tT", "ToggleTerm name=toggleterm-full direction=tab", desc = "Toggle full terminal" }, + { + "tv", + "ToggleTerm direction=vertical name=toggleterm-vert", + desc = "Toggle vertical terminal", + }, + }, opts = { -- size can be a number or function which is passed the current terminal size = function(term) @@ -10,7 +56,6 @@ return { return vim.o.columns * 0.45 end end, - open_mapping = { [[]] }, -- or { [[]], [[]] } if you also use a Japanese keyboard. -- on_create = fun(t: Terminal), -- function to run when the terminal is first created -- on_open = fun(t: Terminal), -- function to run when the terminal opens -- on_close = fun(t: Terminal), -- function to run when the terminal closes @@ -82,4 +127,38 @@ return { horizontal_breakpoint = 135, }, }, + config = function(_, opts) + require("toggleterm").setup(opts) + local Terminal = require("toggleterm.terminal").Terminal + + local programs = { + btop = { cmd = "/usr/bin/btop", display_name = "btop", direction = "tab", hidden = true }, + ipython = { cmd = "ipython", display_name = "ipython", direction = "vertical", hidden = true }, + ["ipython-full"] = { cmd = "ipython", display_name = "ipython-full", direction = "tab", hidden = true }, + iotop = { cmd = "sudo iotop", display_name = "iotop", direction = "tab", hidden = true }, + lazydocker = { cmd = "lazydocker", display_name = "lazydocker", direction = "tab", hidden = true }, + nvtop = { cmd = "nvtop", display_name = "nvtop", direction = "tab", hidden = true }, + rmpc = { cmd = "rmpc", display_name = "rmpc", direction = "tab", hidden = true }, + } + + for name, program in pairs(programs) do + program.on_stderr = function(_, job, data, process_name) + vim.notify( + ("%s encountered an error on job %d\n%s"):format(process_name, job, table.concat(data, "\n")), + vim.log.levels.ERROR + ) + end + terminals[name] = Terminal:new(program) + end + + local terminal_keys = vim.api.nvim_create_augroup("TerminalKeys", { clear = true }) + vim.api.nvim_create_autocmd("TermOpen", { + group = terminal_keys, + pattern = "term://*", + callback = function(args) + vim.keymap.set("t", "", [[]], { buffer = args.buf }) + vim.keymap.set("t", "", [[]], { buffer = args.buf }) + end, + }) + end, } diff --git a/.config/nvim/lua/plugins/vim-commentary.lua b/.config/nvim/lua/plugins/vim-commentary.lua deleted file mode 100644 index db3b0cf..0000000 --- a/.config/nvim/lua/plugins/vim-commentary.lua +++ /dev/null @@ -1 +0,0 @@ -return { "tpope/vim-commentary" } diff --git a/.config/nvim/lua/utils/codecompanion/fidget-spinner-notify.lua b/.config/nvim/lua/utils/codecompanion/fidget-spinner-notify.lua deleted file mode 100644 index 8cfbb29..0000000 --- a/.config/nvim/lua/utils/codecompanion/fidget-spinner-notify.lua +++ /dev/null @@ -1,126 +0,0 @@ -local notify = require("notify") -local spinner_frames = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" } -local spinner_len = #spinner_frames -- cache spinner length -local M = {} -local timeout = 2999 - --- Helper function to safely call notify -local function safe_notify(msg, level, opts) - local ok, res = pcall(notify, msg, level, opts) - return ok, res -end - -function M:init() - local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", {}) - - vim.api.nvim_create_autocmd({ "User" }, { - pattern = "CodeCompanionRequestStarted", - group = group, - callback = function(request) - local handle = M:create_progress_handle(request) - M:store_progress_handle(request.data.id, handle) - end, - }) - - vim.api.nvim_create_autocmd({ "User" }, { - pattern = "CodeCompanionRequestFinished", - group = group, - callback = function(request) - local handle = M:pop_progress_handle(request.data.id) - if handle then - M:report_exit_status(handle, request) - handle:finish() - end - end, - }) -end - -M.handles = {} - -function M:store_progress_handle(id, handle) - M.handles[id] = handle -end - -function M:pop_progress_handle(id) - local handle = M.handles[id] - M.handles[id] = nil - return handle -end - -function M:create_progress_handle(request) - local title = " Requesting assistance" - .. " (" - .. request.data.interaction - .. ") from " - .. request.data.adapter.formatted_name - .. " using " - .. request.data.adapter.model - local idx = 1 - local start_time = os.time() - local notification_id = - notify(spinner_frames[idx] .. " In progress (" .. "0s" .. ")...", "info", { title = title, timeout = false }) - local handle = { notification_id = notification_id, title = title, finished = false } - local timer = vim.loop.new_timer() - timer:start( - 0, - 100, - vim.schedule_wrap(function() - if handle.finished then - return - end -- stop updating if finished - idx = idx % spinner_len + 1 - local elapsed = os.difftime(os.time(), start_time) - local opts = { replace = handle.notification_id, title = title, timeout = false } - local ok, new_id = safe_notify(spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...", "info", opts) - if ok then - handle.notification_id = new_id - else - handle.notification_id = notify( - spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...", - "info", - { title = title, timeout = false } - ) - end - end) - ) - handle.timer = timer - handle.finish = function() - handle.finished = true -- mark as finished to abort future updates - if handle.timer then - handle.timer:stop() - handle.timer:close() - handle.timer = nil - end - end - return handle -end - -function M:report_exit_status(handle, request) - local title = handle.title - or ( - " Requesting assistance" - .. " (" - .. request.data.strategy - .. ") from " - .. request.data.adapter.formatted_name - .. " using " - .. request.data.adapter.model - ) - local function report(msg, level) - local opts = { replace = handle.notification_id, title = title, timeout = timeout } - local ok = safe_notify(msg, level, opts) - if not ok then - notify(msg, level, { title = title, timeout = timeout }) - end - end - - if request.data.status == "success" then - report("Completed", "info") - elseif request.data.status == "error" then - report(" Error", "error") - else - report("󰜺 Cancelled", "warn") - end -end - -return M diff --git a/.config/nvim/lua/utils/codecompanion/fidget-spinner.lua b/.config/nvim/lua/utils/codecompanion/fidget-spinner.lua index bc2bb90..01c87cc 100644 --- a/.config/nvim/lua/utils/codecompanion/fidget-spinner.lua +++ b/.config/nvim/lua/utils/codecompanion/fidget-spinner.lua @@ -1,18 +1,16 @@ --- lua/plugins/codecompanion/fidget-spinner.lua - local progress = require("fidget.progress") local M = {} -function M:init() - local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", {}) +function M.init() + local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", { clear = true }) vim.api.nvim_create_autocmd({ "User" }, { pattern = "CodeCompanionRequestStarted", group = group, callback = function(request) - local handle = M:create_progress_handle(request) - M:store_progress_handle(request.data.id, handle) + local handle = M.create_progress_handle(request) + M.store_progress_handle(request.data.id, handle) end, }) @@ -20,9 +18,9 @@ function M:init() pattern = "CodeCompanionRequestFinished", group = group, callback = function(request) - local handle = M:pop_progress_handle(request.data.id) + local handle = M.pop_progress_handle(request.data.id) if handle then - M:report_exit_status(handle, request) + M.report_exit_status(handle, request) handle:finish() end end, @@ -31,27 +29,28 @@ end M.handles = {} -function M:store_progress_handle(id, handle) +function M.store_progress_handle(id, handle) M.handles[id] = handle end -function M:pop_progress_handle(id) +function M.pop_progress_handle(id) local handle = M.handles[id] M.handles[id] = nil return handle end -function M:create_progress_handle(request) +function M.create_progress_handle(request) + local adapter = request.data.adapter return progress.handle.create({ - title = " Requesting assistance (" .. request.data.adapter.model .. ")", + title = " Requesting assistance (" .. (adapter.model or "default") .. ")", message = "In progress...", lsp_client = { - name = M:llm_role_title(request.data.adapter.name), + name = M.llm_role_title(adapter), }, }) end -function M:llm_role_title(adapter) +function M.llm_role_title(adapter) local parts = {} table.insert(parts, adapter.formatted_name) if adapter.model and adapter.model ~= "" then @@ -60,7 +59,7 @@ function M:llm_role_title(adapter) return table.concat(parts, " ") end -function M:report_exit_status(handle, request) +function M.report_exit_status(handle, request) if request.data.status == "success" then handle.message = "Completed" elseif request.data.status == "error" then diff --git a/.config/nvim/lua/utils/extensions/init.lua b/.config/nvim/lua/utils/extensions/init.lua deleted file mode 100644 index fb1542b..0000000 --- a/.config/nvim/lua/utils/extensions/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - require("utils.extensions.telescope"), -} diff --git a/.config/nvim/lua/utils/extensions/telescope/init.lua b/.config/nvim/lua/utils/extensions/telescope/init.lua deleted file mode 100644 index 89e32b6..0000000 --- a/.config/nvim/lua/utils/extensions/telescope/init.lua +++ /dev/null @@ -1,7 +0,0 @@ -local ts = require("telescope") --- ts.load_extension("fzf") -ts.load_extension("color_names") -ts.load_extension("file_browser") -ts.load_extension("glyph") -ts.load_extension("ui-select") -ts.load_extension("noice") diff --git a/.config/nvim/lua/utils/functions/git_paste/init.lua b/.config/nvim/lua/utils/functions/git_paste/init.lua index 8c2fb74..d718ffc 100644 --- a/.config/nvim/lua/utils/functions/git_paste/init.lua +++ b/.config/nvim/lua/utils/functions/git_paste/init.lua @@ -42,16 +42,4 @@ function M.git_paste_prompt() end) end ---- Sets up the git-paste module. ---- ---- The module expects an optional configuration table: ---- { telescope_key = "pg" } (or any other keymap you prefer) ---- ----@param opts table|nil -function M.setup(opts) - opts = opts or {} - local telescope_key = opts.telescope_key or "pg" - vim.keymap.set("n", telescope_key, M.git_paste_prompt, { desc = "Git Paste: paste content from git raw URL" }) -end - return M diff --git a/.config/nvim/lua/utils/functions/init.lua b/.config/nvim/lua/utils/functions/init.lua deleted file mode 100644 index 082a373..0000000 --- a/.config/nvim/lua/utils/functions/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - require("utils.functions.git_paste"), - require("utils.functions.mkdir_under_cursor"), -} diff --git a/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua b/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua index 2bb6321..5bf130b 100644 --- a/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua +++ b/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua @@ -1,5 +1,4 @@ local M = {} -vim.notify = require("notify") function M.mkdir_under_cursor() local word @@ -19,18 +18,16 @@ function M.mkdir_under_cursor() -- Remove quotes if present word = word:gsub("^[\"']", ""):gsub("[\"']$", "") -- Check if directory exists - local stat = vim.loop.fs_stat(word) + local stat = vim.uv.fs_stat(word) if not stat then - -- Create directory (recursive) - vim.loop.fs_mkdir(word, 493) -- 493 = 0755 in decimal - vim.notify("Directory created: " .. word, vim.log.levels.INFO) + if vim.fn.mkdir(word, "p") == 1 then + vim.notify("Directory created: " .. word, vim.log.levels.INFO) + else + vim.notify("Failed to create directory: " .. word, vim.log.levels.ERROR) + end else vim.notify("Directory already exists: " .. word, vim.log.levels.WARN) end end -function M.setup(opts) - return M.mkdir_under_cursor -end - return M diff --git a/.config/nvim/lua/utils/hyprland/lsp/init.lua b/.config/nvim/lua/utils/hyprland/lsp/init.lua index b0a926f..3c4efb8 100644 --- a/.config/nvim/lua/utils/hyprland/lsp/init.lua +++ b/.config/nvim/lua/utils/hyprland/lsp/init.lua @@ -1,5 +1,3 @@ -vim.notify = require("notify") - local client_notifs = {} local function get_notif_data(client_id, token) @@ -20,7 +18,7 @@ local function update_spinner(client_id, token) local notif_data = get_notif_data(client_id, token) if notif_data.spinner then - local new_spinner = (notif_data.spinner + 1) % #spinner_frames + local new_spinner = (notif_data.spinner % #spinner_frames) + 1 notif_data.spinner = new_spinner notif_data.notification = vim.notify("", nil, { @@ -42,10 +40,12 @@ end local function format_message(message, percentage) return (percentage and percentage .. "%\t" or "") .. (message or "") end + +local hyprland_lsp = vim.api.nvim_create_augroup("HyprlandLsp", { clear = true }) vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + group = hyprland_lsp, pattern = { "*.hl", "hypr*.conf" }, - callback = function(event) - -- print(string.format("starting hyprls for %s", vim.inspect(event))) + callback = function() vim.lsp.start({ name = "hyprlang", cmd = { "hyprls" }, @@ -94,6 +94,7 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { }) notif_data.spinner = nil + client_notifs[client_id][result.token] = nil end end, }, diff --git a/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua b/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua deleted file mode 100644 index d23e0df..0000000 --- a/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua +++ /dev/null @@ -1,19 +0,0 @@ -local M = {} -local map = vim.keymap.set -local opts = { noremap = true, silent = false } - ---- Set keybindings from a table of mappings. ---- @param bindings table A list of keybinding mappings. ---- Each mapping should be a table with the following keys: ---- - mode: string, the mode in which the keybinding applies (e.g., 'n', 'i', 'v'). ---- - key: string, the key to bind. ---- - cmd: string, the command to execute when the key is pressed. ---- - opts: table, optional, additional options for the keybinding (default: -function M.set_keybindings(bindings) - for _, binding in ipairs(bindings) do - map(binding.mode, binding.key, binding.cmd, binding.opts or opts) - end - return bindings -end - -return M diff --git a/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua b/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua deleted file mode 100644 index d093d8b..0000000 --- a/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua +++ /dev/null @@ -1,51 +0,0 @@ -local M = {} - -local whichkey = require("which-key") -vim.notify = require("notify") - ----Helper function to add mappings to which-key ----@param mappings table List of mappings to add ----@param group table Group to add mappings to (optional) ----@return nil ----@usage addToWhichKey(mappings, group) ----@example addToWhichKey({{key = "n", cmd = "next", mode = "n", desc = "Next Line", group = "Navigation"}, {key = "t", group = "example"}) -function M.addToWhichKey(mappings, group) - if group then - whichkey.add({ group.key, group = group.group }) - end - if not mappings and not group then - vim.notify("Error: Mappings is nil", "error") - return - elseif not mappings and group then - return - end - local wk_mappings = {} - for _, mapping in ipairs(mappings) do - wk_mappings = {} - if not mapping.key or mapping.key == "" then - vim.notify("Error: Key is empty or nil", "error") - return - end - - if not mapping.cmd or mapping.cmd == "" then - vim.notify("Error: Command is empty or nil for key: " .. mapping.key, "error") - return - end - - if not mapping.mode or mapping.mode == "" then - vim.notify("Error: Mode is empty or nil for key: " .. mapping.key, "error") - return - end - - wk_mappings[1] = mapping.key - wk_mappings[2] = mapping.cmd - wk_mappings.mode = mapping.mode or "n" - wk_mappings.desc = mapping.desc - if mapping.group then - wk_mappings.group = mapping.group - end - whichkey.add(wk_mappings) - end -end - -return M diff --git a/.config/nvim/lua/utils/keymaps/init.lua b/.config/nvim/lua/utils/keymaps/init.lua deleted file mode 100644 index 5c580c4..0000000 --- a/.config/nvim/lua/utils/keymaps/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - require('utils.keymaps.converters.whichkey'), - require('utils.keymaps.converters.from_table'), -} diff --git a/.config/nvim/lua/utils/telescope_extra/init.lua b/.config/nvim/lua/utils/telescope_extra/init.lua deleted file mode 100644 index 222395c..0000000 --- a/.config/nvim/lua/utils/telescope_extra/init.lua +++ /dev/null @@ -1,50 +0,0 @@ -local telescope = require("telescope") -local telescopeConfig = require("telescope.config") -local actions = require("telescope.actions") - -local M = {} - -function M.find_and_paste_image() - local telescope = require("telescope.builtin") - local actions = require("telescope.actions") - local action_state = require("telescope.actions.state") - - telescope.find_files({ - attach_mappings = function(_, map) - local function embed_image(prompt_bufnr) - local entry = action_state.get_selected_entry() - local filepath = entry[1] - actions.close(prompt_bufnr) - - local img_clip = require("img-clip") - img_clip.paste_image(nil, filepath) - end - - map("i", "", embed_image) - map("n", "", embed_image) - - return true - end, - }) -end - -function M.setup() - -- Clone the default Telescope configuration - local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) } - - -- I want to search in hidden/dot files. - table.insert(vimgrep_arguments, "--hidden") - -- I don't want to search in the `.git` directory. - table.insert(vimgrep_arguments, "--glob") - table.insert(vimgrep_arguments, "!**/.git/*") - vim.tbl_deep_extend("force", telescopeConfig.values, { - mappings = { - i = { - [""] = actions.results_scrolling_left, - [""] = actions.results_scrolling_right, - }, - }, - }) -end - -return M diff --git a/.config/nvim/lua/utils/terminal/init.lua b/.config/nvim/lua/utils/terminal/init.lua deleted file mode 100644 index f0330c0..0000000 --- a/.config/nvim/lua/utils/terminal/init.lua +++ /dev/null @@ -1,6 +0,0 @@ -local M = {} - -M.term_factory = require("utils.terminal.term_factory").term_factory -M.term_toggle = require("utils.terminal.toggle").term_toggle - -return M diff --git a/.config/nvim/lua/utils/terminal/term_factory/init.lua b/.config/nvim/lua/utils/terminal/term_factory/init.lua deleted file mode 100644 index a19200c..0000000 --- a/.config/nvim/lua/utils/terminal/term_factory/init.lua +++ /dev/null @@ -1,12 +0,0 @@ -local Terminal = require("toggleterm.terminal").Terminal -local notify = require("notify") -local M = {} - -function M.term_factory(cfg) - cfg["on_stderr"] = function(_, job, data, name) - notify(name .. " encountered an error on job: " .. job .. "\nData: " .. data, "error") - end - return Terminal:new(cfg) -end - -return M diff --git a/.config/nvim/lua/utils/terminal/toggle/init.lua b/.config/nvim/lua/utils/terminal/toggle/init.lua deleted file mode 100644 index 6488154..0000000 --- a/.config/nvim/lua/utils/terminal/toggle/init.lua +++ /dev/null @@ -1,9 +0,0 @@ -local M = {} - -function M.term_toggle(term) - if term then - term:toggle() - end -end - -return M diff --git a/.config/nvim/lua/utils/treesitter/parsers/hyprlang/init.lua b/.config/nvim/lua/utils/treesitter/parsers/hyprlang/init.lua deleted file mode 100644 index d617dcb..0000000 --- a/.config/nvim/lua/utils/treesitter/parsers/hyprlang/init.lua +++ /dev/null @@ -1,15 +0,0 @@ -local parser_config = require("nvim-treesitter.parsers").get_parser_configs() -parser_config.hyprlang = { - install_info = { - url = "~/github/tree-sitter-hyprlang", -- local path or git repo - files = { "src/parser.c" }, -- note that some parsers also require src/scanner.c or src/scanner.cc - -- optional entries: - branch = "main", -- default branch in case of git repo if different from master - generate_requires_npm = false, -- if stand-alone parser without npm dependencies - requires_generate_from_grammar = true, -- if folder contains pre-generated src/parser.c - }, - filetype = "conf", -- if filetype does not match the parser name -} -vim.filetype.add({ - pattern = { [".*/hypr/.*%.conf"] = "hyprlang" }, -})