From 4ca5b63b751dc7d37efa97862d11b4a894c5c28b Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 26 Sep 2024 22:47:12 +0300 Subject: [PATCH] chore(nvim): more tweaks, cleanup and docs --- config/nvim/.neoconf.json | 24 -------- config/nvim/init.lua | 2 +- config/nvim/lua/options.lua | 17 +++-- config/nvim/lua/plugins/autoformat.lua | 6 +- config/nvim/lua/plugins/cmp.lua | 8 +-- config/nvim/lua/plugins/goto-preview.lua | 4 +- config/nvim/lua/plugins/harpoon.lua | 43 ------------- config/nvim/lua/plugins/lazy.lua | 75 +++-------------------- config/nvim/lua/plugins/lsp.lua | 5 -- config/nvim/lua/plugins/lualine.lua | 2 - config/nvim/lua/plugins/neotree.lua | 3 + config/nvim/lua/plugins/telescope.lua | 51 ++++++++++++++- config/nvim/lua/plugins/ufo.lua | 7 --- config/nvim/lua/plugins/ui.lua | 9 +++ config/nvim/lua/plugins/which-key.lua | 33 +++++++--- config/nvim/spell/en.utf-8.add | 3 + config/nvim/spell/en.utf-8.add.spl | Bin 1562 -> 1578 bytes 17 files changed, 116 insertions(+), 176 deletions(-) delete mode 100644 config/nvim/.neoconf.json delete mode 100644 config/nvim/lua/plugins/harpoon.lua diff --git a/config/nvim/.neoconf.json b/config/nvim/.neoconf.json deleted file mode 100644 index ba9cf17..0000000 --- a/config/nvim/.neoconf.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "neodev": { - "library": { - "enabled": true, - "plugins": [ - "nvim-lspconfig", - "lsp", - "completion" - ] - } - }, - "neoconf": { - "plugins": { - "lua_ls": { - "enabled": true - } - } - }, - "lspconfig": { - "lua_ls": { - "Lua.completion.callSnippet": "Replace" - } - } -} diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 1067693..66a7cbb 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -36,7 +36,7 @@ require('lazy').setup( -- Automatically check for updates enabled = true, -- We don't want to be notified about updates - nofity = false, + notify = false, }, change_detection = { -- No need to notify about changes diff --git a/config/nvim/lua/options.lua b/config/nvim/lua/options.lua index fd695cc..60e4d24 100644 --- a/config/nvim/lua/options.lua +++ b/config/nvim/lua/options.lua @@ -4,6 +4,10 @@ -- See `:help vim.opt` -- For more options, you can see `:help option-list` +-- Enables the experimental nvim 0.5 features +vim.loader.enable() + +-- Map leader and local leader vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' @@ -73,12 +77,6 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 15 --- Enable break indent -vim.o.breakindent = true - --- Save undo history -vim.o.undofile = true - -- Set completeopt to have a better completion experience vim.o.completeopt = 'menuone,noselect' @@ -93,6 +91,13 @@ vim.o.spelllang = 'en_us' vim.g.loaded_perl_provider = 0 vim.g.loaded_ruby_provider = 0 +-- kevinhwang91/nvim-ufo settings +vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] +vim.o.foldcolumn = '1' -- '0' is not bad +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +vim.o.foldenable = true + -- anuvyklack/windows.nvim settings vim.o.winwidth = 15 vim.o.winminwidth = 10 diff --git a/config/nvim/lua/plugins/autoformat.lua b/config/nvim/lua/plugins/autoformat.lua index d8ca19f..58a6189 100644 --- a/config/nvim/lua/plugins/autoformat.lua +++ b/config/nvim/lua/plugins/autoformat.lua @@ -7,11 +7,9 @@ return { keys = { { 'cf', - function() - require('conform').format { async = true, lsp_fallback = true } - end, + 'lua require("conform").format({ async = true, lsp_fallback = true })', mode = '', - desc = '[f] Format buffer', + desc = 'Format buffer', }, }, opts = { diff --git a/config/nvim/lua/plugins/cmp.lua b/config/nvim/lua/plugins/cmp.lua index 874ccf1..9c40037 100644 --- a/config/nvim/lua/plugins/cmp.lua +++ b/config/nvim/lua/plugins/cmp.lua @@ -1,6 +1,6 @@ +-- Auto completion +-- https://github.com/hrsh7th/nvim-cmp return { - -- Auto completion - -- https://github.com/hrsh7th/nvim-cmp { 'hrsh7th/nvim-cmp', lazy = false, @@ -63,7 +63,7 @@ return { require('copilot_cmp').setup() local has_words_before = function() - if vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt' then + if vim.api.nvim_get_option_value('buftype', {}) == 'prompt' then return false end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -142,7 +142,7 @@ return { comparators = { require('copilot_cmp.comparators').prioritize, - -- Below is the default comparitor list and order for nvim-cmp + -- Below is the default comparator list and order for nvim-cmp cmp.config.compare.offset, -- cmp.config.compare.scopes, --this is commented in nvim-cmp too cmp.config.compare.exact, diff --git a/config/nvim/lua/plugins/goto-preview.lua b/config/nvim/lua/plugins/goto-preview.lua index c37aa67..33082f6 100644 --- a/config/nvim/lua/plugins/goto-preview.lua +++ b/config/nvim/lua/plugins/goto-preview.lua @@ -1,6 +1,6 @@ +-- A small Neovim plugin for previewing definitions using floating windows. +-- https://github.com/rmagatti/goto-preview return { - -- A small Neovim plugin for previewing definitions using floating windows. - -- https://github.com/rmagatti/goto-preview 'rmagatti/goto-preview', dependencies = { { 'nvim-telescope/telescope.nvim' }, diff --git a/config/nvim/lua/plugins/harpoon.lua b/config/nvim/lua/plugins/harpoon.lua deleted file mode 100644 index d46ac67..0000000 --- a/config/nvim/lua/plugins/harpoon.lua +++ /dev/null @@ -1,43 +0,0 @@ -return { - -- Getting you where you want with the fewest keystrokes. - -- https://github.com/ThePrimeagen/harpoon - { - 'ThePrimeagen/harpoon', - branch = 'harpoon2', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope.nvim', - }, - config = function() - local harpoon = require 'harpoon' - harpoon:setup {} - - -- basic telescope configuration - local conf = require('telescope.config').values - local function toggle_telescope(harpoon_files) - local file_paths = {} - for _, item in ipairs(harpoon_files.items) do - table.insert(file_paths, item.value) - end - - require('telescope.pickers') - .new({}, { - prompt_title = 'Harpoon', - finder = require('telescope.finders').new_table { - results = file_paths, - }, - previewer = conf.file_previewer {}, - sorter = conf.generic_sorter {}, - }) - :find() - end - - vim.keymap.set('n', 'hw', function() - toggle_telescope(harpoon:list()) - end, { desc = 'Open harpoon window with telescope' }) - vim.keymap.set('n', 'ht', function() - harpoon.ui:toggle_quick_menu(harpoon:list()) - end, { desc = 'Open Harpoon Quick menu' }) - end, - }, -} diff --git a/config/nvim/lua/plugins/lazy.lua b/config/nvim/lua/plugins/lazy.lua index 5026be2..b5967fd 100644 --- a/config/nvim/lua/plugins/lazy.lua +++ b/config/nvim/lua/plugins/lazy.lua @@ -1,89 +1,30 @@ return { + -- A better annotation generator. -- Supports multiple languages and annotation conventions. -- https://github.com/danymat/neogen - { - 'danymat/neogen', - version = '*', - opts = { - enabled = true, - snippet_engine = 'luasnip', - }, - }, + { 'danymat/neogen', version = '*', opts = { enabled = true, snippet_engine = 'luasnip' } }, -- The Refactoring library based off the Refactoring book by Martin Fowler -- https://github.com/ThePrimeagen/refactoring.nvim - { - 'ThePrimeagen/refactoring.nvim', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-treesitter/nvim-treesitter', - }, - config = function() - require('refactoring').setup() - - local r = require 'refactoring' - - vim.keymap.set('x', 're', function() - r.refactor 'Extract Function' - end) - vim.keymap.set('x', 'rf', function() - r.refactor 'Extract Function To File' - end) - -- Extract function supports only visual mode - vim.keymap.set('x', 'rv', function() - r.refactor 'Extract Variable' - end) - -- Extract variable supports only visual mode - vim.keymap.set('n', 'rI', function() - r.refactor 'Inline Function' - end) - -- Inline func supports only normal - vim.keymap.set({ 'n', 'x' }, 'ri', function() - r.refactor 'Inline Variable' - end) - -- Inline var supports both normal and visual mode - - vim.keymap.set('n', 'rb', function() - r.refactor 'Extract Block' - end) - vim.keymap.set('n', 'rbf', function() - r.refactor 'Extract Block To File' - end) - -- Extract block supports only normal mode - end, - }, + { 'ThePrimeagen/refactoring.nvim', dependencies = { 'nvim-lua/plenary.nvim', 'nvim-treesitter/nvim-treesitter' }, opts = {} }, -- All the npm/yarn/pnpm commands I don't want to type -- https://github.com/vuki656/package-info.nvim - { - 'vuki656/package-info.nvim', - dependencies = { 'MunifTanjim/nui.nvim' }, - }, + { 'vuki656/package-info.nvim', dependencies = { 'MunifTanjim/nui.nvim' } }, -- Add/change/delete surrounding delimiter pairs with ease. Written with ❤️ in Lua. -- https://github.com/kylechui/nvim-surround - { - 'kylechui/nvim-surround', - version = '*', -- Use for stability; omit to use `main` branch for the latest features - event = 'VeryLazy', - }, + { 'kylechui/nvim-surround', version = '*', event = 'VeryLazy' }, -- Highlight, list and search todo comments in your projects -- https://github.com/folke/todo-comments.nvim - { - 'folke/todo-comments.nvim', - dependencies = 'nvim-lua/plenary.nvim', - opts = {}, - }, + { 'folke/todo-comments.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, opts = {} }, -- Commenting + -- "gc" to comment visual regions/lines -- https://github.com/numToStr/Comment.nvim - { - 'numToStr/Comment.nvim', -- "gc" to comment visual regions/lines - event = { 'BufRead', 'BufNewFile' }, - opts = {}, - }, + { 'numToStr/Comment.nvim', event = { 'BufRead', 'BufNewFile' }, opts = {} }, -- Detect tabstop and shiftwidth automatically -- https://github.com/tpope/vim-sleuth diff --git a/config/nvim/lua/plugins/lsp.lua b/config/nvim/lua/plugins/lsp.lua index 4c0976e..af4257c 100644 --- a/config/nvim/lua/plugins/lsp.lua +++ b/config/nvim/lua/plugins/lsp.lua @@ -5,11 +5,6 @@ return { 'neovim/nvim-lspconfig', lazy = false, dependencies = { - -- Neovim plugin to manage global and project-local settings - -- Should be included before LSP Config - -- https://github.com/folke/neoconf.nvim - { 'folke/neoconf.nvim', opts = {} }, - -- Garbage collector that stops inactive LSP clients to free RAM -- https://github.com/Zeioth/garbage-day.nvim { diff --git a/config/nvim/lua/plugins/lualine.lua b/config/nvim/lua/plugins/lualine.lua index e99f26a..7c183ab 100644 --- a/config/nvim/lua/plugins/lualine.lua +++ b/config/nvim/lua/plugins/lualine.lua @@ -27,12 +27,10 @@ return { { require('noice').api.statusline.mode.get, cond = require('noice').api.statusline.mode.has, - -- color = { fg = '#ff9e64' }, }, { require('noice').api.status.command.get, cond = require('noice').api.status.command.has, - -- color = { fg = '#ff9e64' }, }, }, }, diff --git a/config/nvim/lua/plugins/neotree.lua b/config/nvim/lua/plugins/neotree.lua index d47315f..1c53d4a 100644 --- a/config/nvim/lua/plugins/neotree.lua +++ b/config/nvim/lua/plugins/neotree.lua @@ -8,6 +8,9 @@ return { 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended 'MunifTanjim/nui.nvim', { + -- This plugins prompts the user to pick a window and returns + -- the window id of the picked window + -- https://github.com/s1n7ax/nvim-window-picker 's1n7ax/nvim-window-picker', version = '2.*', opts = { diff --git a/config/nvim/lua/plugins/telescope.lua b/config/nvim/lua/plugins/telescope.lua index 057d50d..f4ff5e4 100644 --- a/config/nvim/lua/plugins/telescope.lua +++ b/config/nvim/lua/plugins/telescope.lua @@ -8,7 +8,51 @@ return { { 'nvim-lua/plenary.nvim' }, { 'nvim-telescope/telescope-symbols.nvim' }, { 'folke/which-key.nvim' }, - { 'ThePrimeagen/harpoon' }, + -- Getting you where you want with the fewest keystrokes. + -- https://github.com/ThePrimeagen/harpoon + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim', + }, + config = function() + local harpoon = require 'harpoon' + harpoon:setup {} + + -- basic telescope configuration + local conf = require('telescope.config').values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table { + results = file_paths, + }, + previewer = conf.file_previewer {}, + sorter = conf.generic_sorter {}, + }) + :find() + end + + vim.keymap.set('n', 'hw', function() + toggle_telescope(harpoon:list()) + end, { desc = 'Open harpoon window with telescope' }) + vim.keymap.set('n', 'ht', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = 'Open Harpoon Quick menu' }) + end, + }, + -- A Telescope picker to quickly access configurations + -- of plugins managed by lazy.nvim. + -- https://github.com/polirritmico/telescope-lazy-plugins.nvim + { 'polirritmico/telescope-lazy-plugins.nvim' }, -- Fuzzy Finder Algorithm which requires local dependencies to be built. -- Only load if `make` is available @@ -47,16 +91,17 @@ return { -- Load extensions pcall(t.load_extension, 'harpoon') pcall(t.load_extension, 'git_worktree') + pcall(t.load_extension, 'lazy_plugins') + -- Enable telescope fzf native, if installed pcall(t.load_extension, 'fzf') -- [[ Telescope Keymaps ]] -- See `:help telescope.builtin` -- See `:help telescope.keymap` - local b = require 'telescope.builtin' vim.keymap.set('n', '/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. - b.current_buffer_fuzzy_find(themes.get_dropdown { + require('telescope.builtin').current_buffer_fuzzy_find(themes.get_dropdown { winblend = 10, previewer = true, }) diff --git a/config/nvim/lua/plugins/ufo.lua b/config/nvim/lua/plugins/ufo.lua index 8fe77d3..5fbfcb9 100644 --- a/config/nvim/lua/plugins/ufo.lua +++ b/config/nvim/lua/plugins/ufo.lua @@ -15,13 +15,6 @@ return { opts = {}, }, }, - init = function() - vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] - vim.o.foldcolumn = '1' -- '0' is not bad - vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value - vim.o.foldlevelstart = 99 - vim.o.foldenable = true - end, opts = { open_fold_hl_timeout = 150, close_fold_kinds_for_ft = { 'imports', 'comment' }, diff --git a/config/nvim/lua/plugins/ui.lua b/config/nvim/lua/plugins/ui.lua index a3b6cdb..ad974a8 100644 --- a/config/nvim/lua/plugins/ui.lua +++ b/config/nvim/lua/plugins/ui.lua @@ -168,4 +168,13 @@ return { }, opts = {}, }, + + -- Plugin to improve viewing Markdown files in Neovim + -- https://github.com/MeanderingProgrammer/render-markdown.nvim + { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, + ft = 'markdown', + opts = {}, + }, } diff --git a/config/nvim/lua/plugins/which-key.lua b/config/nvim/lua/plugins/which-key.lua index 05a5cde..ab720c5 100644 --- a/config/nvim/lua/plugins/which-key.lua +++ b/config/nvim/lua/plugins/which-key.lua @@ -37,9 +37,7 @@ return { -- ── Code ──────────────────────────────────────────────────────────── { 'c', group = '[c] Code' }, { 'ca', 'lua vim.lsp.buf.code_action()', desc = 'LSP: Code Action' }, - { 'cr', 'lua vim.lsp.buf.rename()', desc = 'LSP: Rename' }, { 'cg', 'lua require("neogen").generate()', desc = 'Generate annotations' }, - -- ── Code: CommentBox ──────────────────────────────────────────────── { 'cb', group = 'CommentBox' }, { 'cbb', 'CBccbox', desc = 'CommentBox: Box Title' }, @@ -47,21 +45,41 @@ return { { 'cbl', 'CBline', desc = 'CommentBox: Simple Line' }, { 'cbm', 'CBllbox14', desc = 'CommentBox: Marked' }, { 'cbt', 'CBllline', desc = 'CommentBox: Titled Line' }, - -- Code: package.json control + -- ── Code: package.json control ────────────────────────────────────── -- See: lua/plugins/lazy.lua { 'cn', group = 'package.json control' }, { 'cnd', 'lua require("package-info").delete()', desc = 'Delete package' }, { 'cni', 'lua require("package-info").install()', desc = 'Install package' }, { 'cns', 'lua require("package-info").show({ force = true })', desc = 'Show package info' }, { 'cnu', 'lua require("package-info").change_version()', desc = 'Change version' }, - -- Code: LSPSaga + -- ── Code: Refactoring ─────────────────────────────────────────────── + { 'cx', group = '[x] Refactoring' }, + { + mode = { 'x' }, + -- Extract function supports only visual mode + { 'cxe', "lua require('refactoring').refactor('Extract Function')", desc = 'Extract Function' }, + { 'cxf', "lua require('refactoring').refactor('Extract Function To File')", desc = 'Extract Function to File' }, + -- Extract variable supports only visual mode + { 'cxv', "lua require('refactoring').refactor('Extract Variable')", desc = 'Extract Variable' }, + }, + -- Inline func supports only normal + { 'cxi', "lua require('refactoring').refactor('Inline Function')", desc = 'Inline Function' }, + -- Extract block supports only normal mode + { 'cxb', "lua require('refactoring').refactor('Extract Block')", desc = 'Extract Block' }, + { 'cxbf', "lua require('refactoring').refactor('Extract Block To File')", desc = 'Extract Block to File' }, + { + mode = { 'n', 'x' }, + -- Inline var supports both normal and visual mode + { 'cxi', "lua require('refactoring').refactor('Inline Variable')", desc = 'Inline Variable' }, + }, + -- ── Code: LSPSaga ─────────────────────────────────────────────────── -- See: lua/plugins/lsp.lua { '', 'Lspsaga term_toggle', desc = 'LSPSaga: Open Floaterm' }, { 'ca', 'Lspsaga code_action', desc = 'LSPSaga: Code Actions' }, { 'cci', 'Lspsaga incoming_calls', desc = 'LSPSaga: Incoming Calls' }, { 'cco', 'Lspsaga outgoing_calls', desc = 'LSPSaga: Outgoing Calls' }, { 'cd', 'Lspsaga show_line_diagnostics', desc = 'LSPSaga: Show Line Diagnostics' }, - { 'cf', 'Lspsaga lsp_finder', desc = 'LSPSaga: LSP Finder' }, + -- cf = Code Format, see: lua/plugins/autoformat.lua { 'ci', 'Lspsaga implement', desc = 'LSPSaga: Implementations' }, { 'cl', 'Lspsaga show_cursor_diagnostics', desc = 'LSPSaga: Show Cursor Diagnostics' }, { 'cp', 'Lspsaga peek_definition', desc = 'LSPSaga: Peek Definition' }, @@ -84,8 +102,8 @@ return { { 'dt', 'DapUiToggle', desc = 'DAP: Toggle UI' }, -- ── Harpoon ───────────────────────────────────────────────────────── + -- See: lua/plugins/telescope.lua { 'h', group = '[h] Harpoon' }, - -- See: lua/plugins/harpoon.lua { 'ha', 'lua require("harpoon"):list():add()', desc = 'harpoon file' }, { 'hn', 'lua require("harpoon"):list():next()', desc = 'harpoon to next file' }, { 'hp', 'lua require("harpoon"):list():prev()', desc = 'harpoon to previous file' }, @@ -106,13 +124,12 @@ return { -- See: lua/plugins/telescope.lua { '', "lua require('telescope.builtin').buffers()", desc = 'Find existing buffers' }, { '', "lua require('telescope.builtin').commands()", desc = 'Telescope: Commands' }, - { 'sS', "lua require('telescope.builtin').git_status()", desc = 'Git Status' }, { 'sd', "lua require('telescope.builtin').diagnostics()", desc = 'Search Diagnostics' }, - { 'sf', "lua require('telescope.builtin').find_files()", desc = 'Search Files' }, { 'sg', "lua require('telescope.builtin').live_grep()", desc = 'Search by Grep' }, { 'sm', 'Telescope harpoon marks', desc = 'Harpoon Marks' }, { 'sn', "lua require('telescope').extensions.notify.notify()", desc = 'Notify' }, { 'so', "lua require('telescope.builtin').oldfiles()", desc = 'Find recently Opened files' }, + { 'sp', "lua require('telescope').extensions.lazy_plugins.lazy_plugins()", desc = 'Find neovim/lazy configs' }, { 'st', 'TodoTelescope', desc = 'Telescope: Todo' }, { 'sw', "lua require('telescope.builtin').grep_string()", desc = 'Search current Word' }, diff --git a/config/nvim/spell/en.utf-8.add b/config/nvim/spell/en.utf-8.add index 1af523c..e376a9e 100644 --- a/config/nvim/spell/en.utf-8.add +++ b/config/nvim/spell/en.utf-8.add @@ -115,3 +115,6 @@ Noice fzf linters LSPConfig +deps +Noice +stdpath diff --git a/config/nvim/spell/en.utf-8.add.spl b/config/nvim/spell/en.utf-8.add.spl index 02aae5ae3bc6f5477fce84e519cc4da1320e3d96..bfd227499aaef8af693bf98bc54d1ff9ec960c42 100644 GIT binary patch delta 355 zcmW+xu}T9$5Z$-8Vv}5@ScH&3iilbzm93qEU?mn79(Su=xOmI$-HHB#U|1^)(Nep^ zBAtzu2=;1cVIf#(u(HtEW!RnBH}l?`J+Ix={LR&Mtz?q){uuKvM*ef1D=@ZD!rprH z*_b|XWoha-nIf=K<_e3PRptpDn(WIj*lV_IrnGMSGA7Q?f|oUbv2X;77%4_j zFoZJdllN7HDzUYsZ%V%+8L!&lsqB&e^N{h2<6Js qHyFReXG+t(D~);2kZ>*)ISz|AcPlGsxd&OMxF52H@4JP$D*gbhOH)7q