diff --git a/.gitignore b/.gitignore index 005b535..8a192ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ test.sh nvim spell/ -lazy-lock.json diff --git a/README.md b/README.md index bf64153..d80d6a5 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,13 @@ git clone https://github.com/Baipyrus/nvim-config.git "${XDG_CONFIG_HOME:-$HOME/ If you're using `cmd.exe`: ```bat -git clone https://github.com/Baipyrus/nvim-config.git %localappdata%\nvim\ +git clone https://github.com/Baipyrus/nvim-config.git "%localappdata%\nvim\" ``` If you're using `powershell.exe` ```pwsh -git clone https://github.com/Baipyrus/nvim-config.git $env:LOCALAPPDATA\nvim\ +git clone https://github.com/Baipyrus/nvim-config.git "${env:LOCALAPPDATA}\nvim" ``` @@ -103,7 +103,7 @@ current plugin status. Hit `q` to close the window. You can apply both of these approaches to any Neovim distribution that you would like to try out. * What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information + * See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information ### Install Recipes diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..518f25e --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,45 @@ +{ + "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conflict-marker.vim": { "branch": "master", "commit": "62742b2ffe7a433988759c67b5c5a22eff74a14b" }, + "conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, + "lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "d4ce7d025f9c7bb4d55ebc4fd88987651e632893" }, + "nvim": { "branch": "main", "commit": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lint": { "branch": "master", "commit": "b3ab4ba88845893663d0b7122ee82921adf28358" }, + "nvim-lspconfig": { "branch": "master", "commit": "541f3a2781de481bb84883889e4d9f0904250a56" }, + "nvim-treesitter": { "branch": "master", "commit": "03452942dfbd998701d4123ccad2090e1bc7e9f1" }, + "nvim-treesitter-context": { "branch": "master", "commit": "78a81c7494e7d1a08dd1200b556933e513fd9f29" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "oil.nvim": { "branch": "master", "commit": "39dbf875861449cf09e936fa80073f3413e9439c" }, + "overseer.nvim": { "branch": "master", "commit": "6f8bc37eb729a00e185cdf38b1ed3309a05bfeef" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, + "vim-flog": { "branch": "master", "commit": "6f80c1ffa7068ca8cc0e29af7af4f6ed0717e65e" }, + "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, + "vim-lastplace": { "branch": "master", "commit": "e58cb0df716d3c88605ae49db5c4741db8b48aa9" }, + "vim-merginal": { "branch": "develop", "commit": "3dca10fd8bce10edbc2024651db4ffb6dd2d89de" }, + "vim-processing": { "branch": "master", "commit": "91aaa18a54f8e507e48353ba87b1eb4ecd82a17c" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" } +} diff --git a/lua/custom/plugins/codeium.lua b/lua/custom/plugins/codeium.lua deleted file mode 100644 index 2ffc237..0000000 --- a/lua/custom/plugins/codeium.lua +++ /dev/null @@ -1,8 +0,0 @@ --- Set keymap to open chat in browser -vim.keymap.set('n', 'cc', ':execute codeium#Chat()', { desc = '[C]odeium [C]hat' }) - -return { - -- Free Github Copilot alternative - 'Exafunction/codeium.vim', - event = 'BufEnter', -} diff --git a/lua/custom/plugins/conflictmarker.lua b/lua/custom/plugins/conflictmarker.lua index 4bc246d..9606fc3 100644 --- a/lua/custom/plugins/conflictmarker.lua +++ b/lua/custom/plugins/conflictmarker.lua @@ -5,40 +5,38 @@ vim.g.conflict_marker_highlight_group = '' vim.g.conflict_marker_begin = '^<<<<<<< .*$' vim.g.conflict_marker_end = '^>>>>>>> .*$' --- Highlight groups -vim.cmd 'highlight ConflictMarkerBegin guibg=#2f7366' -vim.cmd 'highlight ConflictMarkerOurs guibg=#2e5049' -vim.cmd 'highlight ConflictMarkerTheirs guibg=#344f69' -vim.cmd 'highlight ConflictMarkerEnd guibg=#2f628e' -vim.cmd 'highlight ConflictMarkerCommonAncestorsHunk guibg=#754a81' - -- Git conflict marker management plugin return { - 'rhysd/conflict-marker.vim', - config = function() - -- Read all lines in buffer, check if there is any conflict marker - function git_conflict_detection() - local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) - -- Check if strict regex is contained in any line - local beginning = vim.fn.match(lines, vim.g.conflict_marker_begin) - local ending = vim.fn.match(lines, vim.g.conflict_marker_end) - local enabled = vim.diagnostic.is_enabled() - if (beginning > -1 or ending > -1) and enabled then - vim.diagnostic.enable(false) - elseif not enabled then - vim.diagnostic.enable(true) - end - end + { + 'rhysd/conflict-marker.vim', + config = function() + -- Highlight groups + vim.cmd 'highlight ConflictMarkerBegin guibg=#2f7366' + vim.cmd 'highlight ConflictMarkerOurs guibg=#2e5049' + vim.cmd 'highlight ConflictMarkerTheirs guibg=#344f69' + vim.cmd 'highlight ConflictMarkerEnd guibg=#2f628e' + vim.cmd 'highlight ConflictMarkerCommonAncestorsHunk guibg=#754a81' - -- Autocommand to disable diagnostics on buffer enter - vim.api.nvim_create_autocmd('BufRead', { - group = vim.api.nvim_create_augroup('git-conflict-lsp-disable', { clear = true }), - callback = git_conflict_detection, - }) - -- Autocommand to disable diagnostics on save - vim.api.nvim_create_autocmd('BufWritePre', { - group = vim.api.nvim_create_augroup('git-conflict-lsp-disable', { clear = false }), - callback = git_conflict_detection, - }) - end, + -- Read all lines in buffer, check if there is any conflict marker + function git_conflict_detection() + local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) + -- Check if strict regex is contained in any line + local beginning = vim.fn.match(lines, vim.g.conflict_marker_begin) + local ending = vim.fn.match(lines, vim.g.conflict_marker_end) + local enabled = vim.diagnostic.is_enabled() + local conflict = beginning > -1 or ending > -1 + if conflict and enabled then + vim.diagnostic.enable(false) + elseif not conflict and not enabled then + vim.diagnostic.enable(true) + end + end + + -- Autocommand to disable diagnostics on buffer enter + vim.api.nvim_create_autocmd({ 'BufRead', 'BufWritePre' }, { + group = vim.api.nvim_create_augroup('git-conflict-lsp-disable', { clear = true }), + callback = git_conflict_detection, + }) + end, + }, } diff --git a/lua/custom/plugins/fugitive.lua b/lua/custom/plugins/fugitive.lua index 665d462..1732799 100644 --- a/lua/custom/plugins/fugitive.lua +++ b/lua/custom/plugins/fugitive.lua @@ -1,23 +1,28 @@ --- Switch in fugitive.vim status window with the current one -vim.keymap.set('n', 'gs', 'Gedit :', { desc = '[G]it [S]tatus' }) --- Fetch all changes -vim.keymap.set('n', 'gF', 'Git fetch', { desc = '[G]it [F]etch' }) --- Push changes -vim.keymap.set('n', 'gP', 'Git push', { desc = '[G]it [P]ush' }) --- Pull changes -vim.keymap.set('n', 'gp', 'Git pull', { desc = '[G]it [P]ull' }) --- Open history graph -vim.keymap.set('n', 'gl', 'Flogsplitwincmd kq', { desc = '[G]it [L]og' }) - return { - -- Git related plugins - 'tpope/vim-fugitive', - dependencies = { - { - 'rbong/vim-flog', - lazy = true, - cmd = { 'Flogsplit' }, + { + -- Git related plugins + 'tpope/vim-fugitive', + dependencies = { + { + 'rbong/vim-flog', + lazy = true, + cmd = { 'Flogsplit' }, + }, + 'idanarye/vim-merginal', }, - 'idanarye/vim-merginal', + config = function() + -- Switch in fugitive.vim status window with the current one + vim.keymap.set('n', 'gs', 'Gedit :', { desc = '[G]it [S]tatus' }) + -- Fetch all changes + vim.keymap.set('n', 'gF', 'Git fetch', { desc = '[G]it [F]etch' }) + -- Push changes + vim.keymap.set('n', 'gP', 'Git push', { desc = '[G]it [P]ush' }) + -- Pull changes + vim.keymap.set('n', 'gp', 'Git pull', { desc = '[G]it [P]ull' }) + -- Open history graph + vim.keymap.set('n', 'gl', 'Flogsplitwincmd kq', { desc = '[G]it [L]og' }) + -- Open branch manager + vim.keymap.set('n', 'gm', 'Merginal', { desc = '[G]it [M]erginal' }) + end, }, } diff --git a/lua/custom/plugins/lastplace.lua b/lua/custom/plugins/lastplace.lua index 0859311..61e50c4 100644 --- a/lua/custom/plugins/lastplace.lua +++ b/lua/custom/plugins/lastplace.lua @@ -1,4 +1,6 @@ -- Plugin to intelligently reopen files at last edit position return { - 'farmergreg/vim-lastplace', + { + 'farmergreg/vim-lastplace', + }, } diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua index 59c98e6..070430a 100644 --- a/lua/custom/plugins/lualine.lua +++ b/lua/custom/plugins/lualine.lua @@ -1,13 +1,15 @@ return { - -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = vim.g.have_nerd_font, - theme = 'catppuccin', - section_separators = { left = '', right = '' }, - component_separators = { left = '', right = '' }, + { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = vim.g.have_nerd_font, + theme = 'catppuccin', + section_separators = { left = '', right = '' }, + component_separators = { left = '', right = '' }, + }, }, }, } diff --git a/lua/custom/plugins/markdown.lua b/lua/custom/plugins/markdown.lua index 53baa36..79e6d9c 100644 --- a/lua/custom/plugins/markdown.lua +++ b/lua/custom/plugins/markdown.lua @@ -1,10 +1,12 @@ -- Markdown preview plugin return { - 'iamcco/markdown-preview.nvim', - cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, - build = 'cd app; npm install', - init = function() - vim.g.mkdp_filetypes = { 'markdown' } - end, - ft = { 'markdown' }, + { + 'iamcco/markdown-preview.nvim', + cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, + build = 'cd app; npm install', + init = function() + vim.g.mkdp_filetypes = { 'markdown' } + end, + ft = { 'markdown' }, + }, } diff --git a/lua/custom/plugins/neoscroll.lua b/lua/custom/plugins/neoscroll.lua index 61b9ac7..5dfa325 100644 --- a/lua/custom/plugins/neoscroll.lua +++ b/lua/custom/plugins/neoscroll.lua @@ -1,28 +1,30 @@ -- Smooth scroll plugin and keymaps return { - 'karb94/neoscroll.nvim', - enabled = not vim.g.neovide, - config = function() - require('neoscroll').setup { - hide_cursor = false, - easing_function = nil, - respect_scrolloff = true, - } + { + 'karb94/neoscroll.nvim', + enabled = not vim.g.neovide, + config = function() + require('neoscroll').setup { + hide_cursor = false, + easing_function = nil, + respect_scrolloff = true, + } - require('neoscroll.config').set_mappings { - -- Scroll normally - [''] = { 'scroll', { '-vim.wo.scroll', 'true', '50' } }, - [''] = { 'scroll', { 'vim.wo.scroll', 'true', '50' } }, - -- Scroll entire page height - [''] = { 'scroll', { '-vim.api.nvim_win_get_height(0)', 'true', '80' } }, - [''] = { 'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '80' } }, - -- Scroll 10% at a time - [''] = { 'scroll', { '-0.10', 'false', '25' } }, - [''] = { 'scroll', { '0.10', 'false', '25' } }, - -- Jump to top, bottom and center - ['zt'] = { 'zt', { '40' } }, - ['zz'] = { 'zz', { '50' } }, - ['zb'] = { 'zb', { '40' } }, - } - end, + require('neoscroll.config').set_mappings { + -- Scroll normally + [''] = { 'scroll', { '-vim.wo.scroll', 'true', '50' } }, + [''] = { 'scroll', { 'vim.wo.scroll', 'true', '50' } }, + -- Scroll entire page height + [''] = { 'scroll', { '-vim.api.nvim_win_get_height(0)', 'true', '80' } }, + [''] = { 'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '80' } }, + -- Scroll 10% at a time + [''] = { 'scroll', { '-0.10', 'false', '25' } }, + [''] = { 'scroll', { '0.10', 'false', '25' } }, + -- Jump to top, bottom and center + ['zt'] = { 'zt', { '40' } }, + ['zz'] = { 'zz', { '50' } }, + ['zb'] = { 'zb', { '40' } }, + } + end, + }, } diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua index ed6ae3a..f9bae0e 100644 --- a/lua/custom/plugins/oil.lua +++ b/lua/custom/plugins/oil.lua @@ -1,20 +1,33 @@ --- Fix oil absolute path to relative path conversion -vim.api.nvim_create_augroup('OilRelPathFix', {}) -vim.api.nvim_create_autocmd('BufLeave', { - group = 'OilRelPathFix', - pattern = 'oil:///*', - callback = function() - vim.cmd 'cd .' - end, -}) - return { - 'stevearc/oil.nvim', - opts = {}, - -- Optional dependencies - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - require('oil').setup() - vim.keymap.set('n', 'fe', require('oil').open, { desc = '[F]ile [E]xplorer' }) - end, + { + 'stevearc/oil.nvim', + -- Optional dependencies + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + -- Fix oil absolute path to relative path conversion + vim.api.nvim_create_augroup('OilRelPathFix', {}) + vim.api.nvim_create_autocmd('BufLeave', { + group = 'OilRelPathFix', + pattern = 'oil:///*', + callback = function() + vim.cmd 'cd .' + end, + }) + + local oil = require 'oil' + oil.setup { + view_options = { + show_hidden = true, + }, + } + + vim.keymap.set('n', 'fe', function() + if vim.bo.filetype == 'oil' then + oil.close() + else + oil.open() + end + end, { desc = '[F]ile [E]xplorer' }) + end, + }, } diff --git a/lua/custom/plugins/overseer.lua b/lua/custom/plugins/overseer.lua index 51946f0..fa23203 100644 --- a/lua/custom/plugins/overseer.lua +++ b/lua/custom/plugins/overseer.lua @@ -1,47 +1,61 @@ return { - -- Simple task runner plugin - 'stevearc/overseer.nvim', - opts = {}, - config = function() - local overseer = require 'overseer' - overseer.setup { - templates = { - 'builtin', - 'golang.run_project', - 'golang.run_file', - }, - task_list = { - bindings = { - [''] = false, - [''] = false, - [''] = false, - [''] = false, - ['q'] = false, + { + -- Simple task runner plugin + 'stevearc/overseer.nvim', + opts = {}, + config = function() + local overseer = require 'overseer' + overseer.setup { + templates = { + 'builtin', + 'golang.run_project', + 'golang.run_file', }, - }, - } + task_list = { + bindings = { + [''] = false, + [''] = false, + [''] = false, + [''] = false, + ['q'] = false, + }, + }, + } - -- Reference: overseer.nvim/lua/overseer/window.lua - local function is_open() - for _, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do - local bufnr = vim.api.nvim_win_get_buf(winid) - if vim.bo[bufnr].filetype == 'OverseerList' then - return true + -- Reference: overseer.nvim/lua/overseer/window.lua + local function is_open() + for _, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do + local bufnr = vim.api.nvim_win_get_buf(winid) + if vim.bo[bufnr].filetype == 'OverseerList' then + return true + end end + return false end - return false - end - -- Display status info about tasks - vim.keymap.set('n', 'ol', function() - overseer.toggle { winid = 0 } - if is_open() then - vim.cmd.winc '_' - else - vim.api.nvim_buf_delete(vim.api.nvim_get_current_buf(), {}) - end - end, { desc = '[O]verseer [L]og' }) - -- Run task by listing all in floating - vim.keymap.set('n', 'or', 'OverseerRun', { desc = '[O]verseer [R]un' }) - end, + -- Display status info about tasks + vim.keymap.set('n', 'ol', function() + -- Get currently open windows (detects splits) + local curWindows = #vim.api.nvim_tabpage_list_wins(0) + -- Use builtin toggle if already using splits + if curWindows ~= (is_open() and 2 or 1) then + vim.cmd 'OverseerToggle' + return + end + + -- Otherwise, toggle overseer in fullscreen + overseer.toggle { winid = 0 } + local bufnr = vim.api.nvim_get_current_buf() + if is_open() then + -- Maximize height + vim.cmd.winc '_' + elseif vim.bo[bufnr].filetype == '' and vim.bo.buftype ~= 'terminal' then + -- Delete empty buffer created by overseer + vim.api.nvim_buf_delete(bufnr, {}) + end + end, { desc = '[O]verseer [L]og' }) + -- Run task by listing all in floating + vim.keymap.set('n', 'or', 'OverseerRun', { desc = '[O]verseer [R]un' }) + end, + }, } diff --git a/lua/custom/plugins/vimbbye.lua b/lua/custom/plugins/vimbbye.lua new file mode 100644 index 0000000..7b9d0f2 --- /dev/null +++ b/lua/custom/plugins/vimbbye.lua @@ -0,0 +1,8 @@ +return { + { + 'moll/vim-bbye', + config = function() + vim.keymap.set('n', 'bd', 'Bdelete', { desc = '[B]uffer [D]elete' }) + end, + }, +} diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 93be8db..1e75fd9 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -1,15 +1,15 @@ -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` --- Set highlight on search, but clear on pressing in normal mode -vim.opt.hlsearch = true +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +vim.keymap.set('n', 'q', vim.diagnostic.setqflist, { desc = 'Open diagnostic [Q]uickfix list' }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping @@ -33,11 +33,6 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) --- Delete (currently selected) text without yanking it -vim.keymap.set({ 'n', 'v' }, 'dny', '"_d', { desc = '[D]elete [N]o [Y]ank' }) --- Replace currently selected text with default register without yanking it -vim.keymap.set('v', 'pny', '"_dP', { desc = '[P]aste [N]o [Y]ank' }) - -- Populate CMD to prepare for change directory vim.keymap.set('n', 'cd ', ':cd ', { desc = 'Prepare CMD for [C]hange [D]irectory' }) -- Navigate to 'base' directory, the initial dir that nvim was run in @@ -47,15 +42,6 @@ vim.keymap.set('n', 'cdh', 'cd ' .. vim.env.HOME .. '', { desc -- Automatically navigate to config directory vim.keymap.set('n', 'cdn', 'cd ' .. vim.fn.stdpath 'config' .. '', { desc = '[C]hange [D]irectory to [N]eovim' }) --- Delete current buffer without closing window -vim.keymap.set('n', 'bd', function() - -- Get current buffer - local buf = vim.api.nvim_get_current_buf() - -- Switch to different buffer - vim.cmd 'bp' - -- Delete saved buffer - vim.api.nvim_buf_delete(buf, {}) -end, { desc = '[B]uffer [D]elete' }) -- Switch to between buffers vim.keymap.set('n', 'bp', 'bp', { desc = '[B]uffer [P]revious' }) vim.keymap.set('n', 'bn', 'bn', { desc = '[B]uffer [N]ext' }) @@ -125,8 +111,8 @@ vim.keymap.set({ 'n', 'v' }, 'gy', global_cmd_yank, { desc = '[G]lobal c -- Fix filename keymap vim.keymap.set({ 'n', 'v' }, 'fp', function() -- lua print(string.gsub(vim.api.nvim_buf_get_name(0), vim.fn.getcwd(), '')) - local cwd = vim.fn.getcwd() - local path = vim.api.nvim_buf_get_name(0) + local cwd = vim.fn.getcwd():lower() + local path = vim.api.nvim_buf_get_name(0):lower() local file, _ = string.gsub(path, cwd .. '\\', '') vim.cmd('0f | file ' .. file) end, { desc = '[F]ile Fix Relative [P]ath' }) @@ -137,6 +123,8 @@ if vim.g.neovide then vim.keymap.set({ 'n', 'v' }, '', '"+p', { desc = 'Paste from System clipboard' }) -- Clipboard for command and insert mode vim.keymap.set({ 'c', 'i' }, '', '+', { desc = 'Paste from System clipboard' }) + -- Clipboard for terminal mode + vim.keymap.set({ 't' }, '', '"+pi', { desc = 'Paste from System clipboard' }) end -- [[ Basic Autocommands ]] diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 52d68af..476b80b 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -7,7 +7,7 @@ return { { 'fb', function() - require('conform').format { async = true, lsp_fallback = true } + require('conform').format { async = true, lsp_format = 'fallback' } end, mode = '', desc = '[F]ormat [B]uffer', @@ -20,9 +20,15 @@ return { -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true, cpp = true, php = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end return { timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], + lsp_format = lsp_format_opt, } end, formatters_by_ft = { @@ -30,9 +36,8 @@ return { -- Conform can also run multiple formatters sequentially python = { 'isort', 'black' }, - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - javascript = { { 'prettierd', 'prettier' } }, + -- You can use 'stop_after_first' to run the first available formatter from the list + javascript = { 'prettierd', 'prettier', stop_after_first = true }, }, }, }, diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 7e1a50f..e559136 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -8,6 +8,7 @@ return { lint.linters_by_ft = { javascript = { 'eslint' }, typescript = { 'eslint' }, + php = { 'eslint' }, markdown = { 'markdownlint' }, } @@ -17,7 +18,7 @@ return { vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { group = lint_augroup, callback = function() - lint.try_lint() + lint.try_lint(nil, { ignore_errors = true }) end, }) end, diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 8d14c30..98eded4 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -1,5 +1,20 @@ +-- LSP Plugins return { - { -- LSP Configuration & Plugins + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + { 'Bilal2453/luvit-meta', lazy = true }, + { + -- Main LSP Configuration 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs and related tools to stdpath for Neovim @@ -12,19 +27,8 @@ return { -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - { - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, - }, - }, - { 'Bilal2453/luvit-meta', lazy = true }, + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', }, config = function() -- Brief aside: **What is LSP?** @@ -64,8 +68,9 @@ return { -- -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end -- Jump to the definition of the word under your cursor. @@ -102,11 +107,13 @@ return { -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap. map('K', vim.lsp.buf.hover, 'Hover Documentation') + -- Similar as above, shows hover documentation for current function + vim.keymap.set('i', '', vim.lsp.buf.signature_help, { buffer = event.buf, desc = 'LSP: ' .. 'Hover Signature Information' }) -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. @@ -170,12 +177,13 @@ return { -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { + powershell_es = {}, rust_analyzer = {}, tailwindcss = {}, omnisharp = {}, - tsserver = {}, pyright = {}, svelte = {}, + ts_ls = {}, gopls = {}, intelephense = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -308,7 +316,7 @@ return { local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) + -- certain features of an LSP (for example, turning off formatting for ts_ls) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua index 37aa1e4..7e0eb68 100644 --- a/lua/kickstart/plugins/telescope.lua +++ b/lua/kickstart/plugins/telescope.lua @@ -111,8 +111,12 @@ return { vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'sr', function() + builtin.oldfiles { + only_cwd = true, + } + end, { desc = '[S]earch [R]ecent Files in CWD' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Global Files' }) vim.keymap.set('n', 'sc', builtin.command_history, { desc = '[S]earch [C]ommand History' }) vim.keymap.set('n', '', function() builtin.buffers { diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index bfa5b95..73e88c0 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -6,6 +6,8 @@ return { 'nvim-treesitter/nvim-treesitter-textobjects', }, build = ':TSUpdate', + main = 'nvim-treesitter.configs', -- Sets main module to use for opts + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { ensure_installed = { -- kickstart @@ -30,6 +32,7 @@ return { 'rust', 'c_sharp', 'go', + 'powershell', -- git 'gitcommit', 'gitignore', @@ -102,14 +105,6 @@ return { }, }, }, - config = function(_, opts) - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - -- Prefer git instead of curl in order to improve connectivity in some environments - require('nvim-treesitter.install').prefer_git = true - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup(opts) - end, }, } -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/kickstart/plugins/which-key.lua b/lua/kickstart/plugins/which-key.lua index a0d711f..107cae1 100644 --- a/lua/kickstart/plugins/which-key.lua +++ b/lua/kickstart/plugins/which-key.lua @@ -17,12 +17,49 @@ return { { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() + opts = { + icons = { + -- set icon mappings to true if you have a Nerd Font + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, + -- Document existing key chains - require('which-key').add { + spec = { { 'c', group = '[C]ode-/[C]hange' }, - { 'd', group = '[D]ocument/[D]elete', mode = { 'n', 'v' } }, + { 'c', group = '[C]ode', mode = { 'x' } }, + { 'd', group = '[D]ocument' }, { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, @@ -31,14 +68,11 @@ return { { 'g', group = '[G]it/[G]lobal', mode = { 'n', 'v' } }, { 'b', group = '[B]uffer/[B]reakpoint' }, { 'cd', group = '[D]irectory' }, - { 'dn', group = '[N]o', mode = { 'n', 'v' } }, { 'l', group = '[L]ist', mode = { 'n', 'v' } }, { 'f', group = '[F]ormat/[F]ile', mode = { 'n', 'v' } }, { 'o', group = '[O]verseer', mode = { 'n', 'v' } }, - { 'p', group = '[P]aste', mode = { 'v' } }, - { 'pn', group = '[N]o', mode = { 'v' } }, - } - end, + }, + }, }, } -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/lazy-bootstrap.lua b/lua/lazy-bootstrap.lua index 9f80e1a..f83dda5 100644 --- a/lua/lazy-bootstrap.lua +++ b/lua/lazy-bootstrap.lua @@ -1,7 +1,7 @@ -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.uv.fs_stat(lazypath) then +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', diff --git a/lua/options.lua b/lua/options.lua index 35f726e..a43fa62 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -4,12 +4,12 @@ -- For more options, you can see `:help option-list` -- Set display language -vim.cmd('language en_US', {}) +vim.cmd 'silent! language en_US' -- Shell options --- Sets the shell to use for system() and ! commands in windows -if vim.fn.has 'win32' == 1 and vim.fn.has 'wsl' == 0 then - vim.opt.shell = vim.fn.executable 'pwsh' == 1 and 'pwsh' or 'powershell' +-- Sets the shell to use for system() and ! commands in windows and wsl +if vim.fn.has 'win32' == 1 or vim.fn.has 'wsl' == 1 then + vim.opt.shell = vim.fn.executable 'pwsh.exe' == 1 and 'pwsh.exe' or 'powershell.exe' vim.opt.shellcmdflag = '-NoLogo -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' vim.opt.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' vim.opt.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' @@ -38,9 +38,12 @@ vim.opt.mouse = 'a' vim.opt.showmode = false -- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.opt.clipboard = 'unnamedplus' +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) -- Enable break indent vim.opt.breakindent = true @@ -89,12 +92,21 @@ vim.opt.sidescrolloff = 12 -- Set cursor pointer to block vim.opt.guicursor = 'n-v-i-c:block-Cursor' --- Options specifically targeted at Neovide -if vim.g.neovide then - vim.o.guifont = 'CaskaydiaCove Nerd Font Mono:h14' - vim.g.neovide_hide_mouse_when_typing = true - vim.g.neovide_cursor_animation_length = 0 - vim.g.neovide_cursor_trail_length = 0 -end +-- Set global statusline +vim.o.laststatus = 3 +vim.api.nvim_set_hl(0, 'WinSeparator', { bg = nil }) + +vim.api.nvim_create_autocmd('UIEnter', { + group = vim.api.nvim_create_augroup('SetGUISettings', { clear = true }), + callback = function() + -- Options specifically targeted at Neovide + if vim.g.neovide then + vim.o.guifont = 'CaskaydiaCove Nerd Font Mono:h14' + vim.g.neovide_hide_mouse_when_typing = true + vim.g.neovide_cursor_animation_length = 0 + vim.g.neovide_cursor_trail_length = 0 + end + end, +}) -- vim: ts=2 sts=2 sw=2 et