diff options
Diffstat (limited to 'nvim')
33 files changed, 746 insertions, 660 deletions
diff --git a/nvim/.config/nvim/.gitignore b/nvim/.config/nvim/.gitignore new file mode 100644 index 0000000..8b8b7d9 --- /dev/null +++ b/nvim/.config/nvim/.gitignore @@ -0,0 +1,2 @@ +/venv + diff --git a/nvim/.config/nvim/ftdetect/tpl.lua b/nvim/.config/nvim/ftdetect/tpl.lua new file mode 100644 index 0000000..f1ec161 --- /dev/null +++ b/nvim/.config/nvim/ftdetect/tpl.lua @@ -0,0 +1,6 @@ +vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { + pattern = '*.sh.tpl', + callback = function() + vim.bo.filetype = 'sh' + end, +}) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 0078035..d533348 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,41 +1,34 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "f1d6bb5aa7219cfb426c2f585362b866f1dbb7d9" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, - "copilot.lua": { "branch": "master", "commit": "0f2fd3829dd27d682e46c244cf48d9715726f612" }, - "fidget.nvim": { "branch": "main", "commit": "dafd592c7bdbb6cd6d17d3c9a1a8abf3930138c1" }, - "gitsigns.nvim": { "branch": "main", "commit": "c7d37ca22b461f64e26f8f6701b2586128ed0bef" }, + "fidget.nvim": { "branch": "main", "commit": "2cb5edb2dd6700a958a446b20bb2be04d318da9d" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, + "lazygit.nvim": { "branch": "main", "commit": "3c524ebec6072568064235c407195e9f9fd0cb8a" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "7f0bf635082bb9b7d2b37766054526a6ccafdb85" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "86389a3dd687cfaa647b6f44731e492970034baa" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, "mini.icons": { "branch": "main", "commit": "b8f6fa6f5a3fd0c56936252edcd691184e5aac0c" }, - "mini.nvim": { "branch": "main", "commit": "4035ef97407a6661ae9ff913ff980e271a658502" }, - "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "mini.nvim": { "branch": "main", "commit": "301ee9f3afa2224b833de7c182574ba6c61e8c6e" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "a479e25ed5b5d331fb46ee4b9e160ff02ac64310" }, - "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, - "nvim-dap-python": { "branch": "master", "commit": "261ce649d05bc455a29f9636dc03f8cdaa7e0e2c" }, - "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, "nvim-lint": { "branch": "master", "commit": "7ef127aaede2a4d5ad8df8321e2eb4e567f29594" }, - "nvim-lspconfig": { "branch": "master", "commit": "d6dc63670d3dc5204b1e874af4cbf340cb5d9d18" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-lspconfig": { "branch": "master", "commit": "6f5ea94fa12bada33dcb26161170e59d679b719f" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "3362099de3368aa620a8105b19ed04c2053e38c0" }, + "nvim-treesitter-context": { "branch": "master", "commit": "dca8726fea2c14e1ce6adbaa76a04816fbfaff61" }, + "nvim-web-devicons": { "branch": "master", "commit": "c2599a81ecabaae07c49ff9b45dcd032a8d90f1a" }, "oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } diff --git a/nvim/.config/nvim/lua/eugenetriguba/autocmds.lua b/nvim/.config/nvim/lua/eugenetriguba/autocmds.lua index 145d00a..01d6aff 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/autocmds.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/autocmds.lua @@ -6,3 +6,10 @@ vim.api.nvim_create_autocmd('TextYankPost', { vim.hl.on_yank() end, }) + +vim.api.nvim_create_autocmd('FileType', { + callback = function() + vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, +}) diff --git a/nvim/.config/nvim/lua/eugenetriguba/global.lua b/nvim/.config/nvim/lua/eugenetriguba/global.lua index 41f48e4..f31ae13 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/global.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/global.lua @@ -6,3 +6,4 @@ vim.g.maplocalleader = ' ' -- Set Python 3 to a virtual environment with `pynvim` installed -- to support python plugins. vim.g.python3_host_prog = vim.fn.expand '~/.config/nvim/venv/bin/python' + diff --git a/nvim/.config/nvim/lua/eugenetriguba/init.lua b/nvim/.config/nvim/lua/eugenetriguba/init.lua index d372afd..ac79aec 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/init.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/init.lua @@ -1,5 +1,5 @@ require 'eugenetriguba.global' +require 'eugenetriguba.lazy' require 'eugenetriguba.keymaps' require 'eugenetriguba.autocmds' require 'eugenetriguba.options' -require 'eugenetriguba.plugins' diff --git a/nvim/.config/nvim/lua/eugenetriguba/keymaps.lua b/nvim/.config/nvim/lua/eugenetriguba/keymaps.lua index a63dcea..e952e0f 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/keymaps.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/keymaps.lua @@ -1,5 +1,8 @@ local map = vim.keymap.set +map('n', '<leader>sh', ':split<CR>') +map('n', '<leader>sv', ':vsplit<CR>') + -- Clear highlights on search when pressing <Esc> in normal mode map('n', '<Esc>', '<cmd>nohlsearch<CR>') @@ -19,6 +22,13 @@ map('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) map('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) map('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) --- Keybindings to cycle through open buffers easier -map('n', '<M-,>', '<cmd>bprev<CR>', { desc = 'Open buffer to the left' }) -map('n', '<M-.>', '<cmd>bnext<CR>', { desc = 'Open buffer to the right' }) +local function confirm_and_delete_buffer() + local confirm = vim.fn.confirm('Delete buffer and file?', '&Y\n&N', 2) + + if confirm == 1 then + os.remove(vim.fn.expand '%') + vim.api.nvim_buf_delete(0, { force = true }) + end +end + +map('n', '<leader>df', confirm_and_delete_buffer) diff --git a/nvim/.config/nvim/lua/eugenetriguba/lazy.lua b/nvim/.config/nvim/lua/eugenetriguba/lazy.lua new file mode 100644 index 0000000..ff5b33d --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/lazy.lua @@ -0,0 +1,23 @@ +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { 'Failed to clone lazy.nvim:\n', 'ErrorMsg' }, + { out, 'WarningMsg' }, + { '\nPress any key to exit...' }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup { + spec = { + { import = 'eugenetriguba.plugins' }, + }, + install = { colorscheme = { 'tokyonight' } }, + checker = { enabled = true, notify = false }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/barbar.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/barbar.lua new file mode 100644 index 0000000..7056c97 --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/barbar.lua @@ -0,0 +1,70 @@ +return { + { + 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', + 'nvim-tree/nvim-web-devicons', + }, + init = function() + vim.g.barbar_auto_setup = false + end, + version = '^1.0.0', + config = function() + require('barbar').setup {} + + local map = vim.api.nvim_set_keymap + local opts = { noremap = true, silent = true } + + -- Move to previous/next + map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts) + map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts) + + -- Re-order to previous/next + map('n', '<A-<>', '<Cmd>BufferMovePrevious<CR>', opts) + map('n', '<A->>', '<Cmd>BufferMoveNext<CR>', opts) + + -- Goto buffer in position... + map('n', '<A-1>', '<Cmd>BufferGoto 1<CR>', opts) + map('n', '<A-2>', '<Cmd>BufferGoto 2<CR>', opts) + map('n', '<A-3>', '<Cmd>BufferGoto 3<CR>', opts) + map('n', '<A-4>', '<Cmd>BufferGoto 4<CR>', opts) + map('n', '<A-5>', '<Cmd>BufferGoto 5<CR>', opts) + map('n', '<A-6>', '<Cmd>BufferGoto 6<CR>', opts) + map('n', '<A-7>', '<Cmd>BufferGoto 7<CR>', opts) + map('n', '<A-8>', '<Cmd>BufferGoto 8<CR>', opts) + map('n', '<A-9>', '<Cmd>BufferGoto 9<CR>', opts) + map('n', '<A-0>', '<Cmd>BufferLast<CR>', opts) + + -- Pin/unpin buffer + map('n', '<A-p>', '<Cmd>BufferPin<CR>', opts) + + -- Goto pinned/unpinned buffer + -- :BufferGotoPinned + -- :BufferGotoUnpinned + + -- Close buffer + map('n', '<A-c>', '<Cmd>BufferClose<CR>', opts) + + -- Wipeout buffer + -- :BufferWipeout + + -- Close commands + -- :BufferCloseAllButCurrent + -- :BufferCloseAllButPinned + -- :BufferCloseAllButCurrentOrPinned + -- :BufferCloseBuffersLeft + -- :BufferCloseBuffersRight + + -- Magic buffer-picking mode + map('n', '<C-p>', '<Cmd>BufferPick<CR>', opts) + map('n', '<C-s-p>', '<Cmd>BufferPickDelete<CR>', opts) + + -- Sort automatically by... + map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts) + map('n', '<Space>bn', '<Cmd>BufferOrderByName<CR>', opts) + map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', opts) + map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', opts) + map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts) + end, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/blink.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/blink.lua index e5ff5fb..a4fd085 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/blink.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/blink.lua @@ -1,127 +1,62 @@ -vim.pack.add { +return { { - name = 'blink.cmp', - src = 'https://github.com/saghen/blink.cmp', - }, - { - name = 'LuaSnip', - src = 'https://github.com/L3MON4D3/LuaSnip', - }, - { - name = 'friendly-snippets', - src = 'https://github.com/rafamadriz/friendly-snippets', - }, - { - name = 'lazydev.nvim', - src = 'https://github.com/folke/lazydev.nvim', - }, -} - -local lsp = vim.api.nvim_create_augroup('lsp', { clear = true }) -vim.api.nvim_create_autocmd('FileType', { - desc = 'Setup lua lsp on lua filetype', - pattern = 'lua', - group = lsp, - callback = function() - require('lazydev').setup { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + 'https://github.com/saghen/blink.cmp', + build = 'cargo +nightly build --release', + event = 'VimEnter', + version = '*', + dependencies = { + { + 'https://github.com/L3MON4D3/LuaSnip', + version = '2.*', + build = (function() + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, + }, + opts = {}, + }, + 'https://github.com/folke/lazydev.nvim', + 'https://github.com/giuxtaposition/blink-cmp-copilot', + }, + --- @module 'blink.cmp' + --- @type blink.cmp.Config + opts = { + keymap = { + preset = 'default', }, - } - end, -}) - -require('luasnip').setup {} -require('luasnip.loaders.from_vscode').lazy_load() -- load friendly-snippets - -require('blink.cmp').setup { - keymap = { - preset = 'default', - }, - appearance = { - nerd_font_variant = 'mono', - }, + appearance = { + nerd_font_variant = 'mono', + }, - completion = { - documentation = { - auto_show = true, - auto_show_delay_ms = 500, - }, - }, + completion = { + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + }, - sources = { - default = { - 'lsp', - 'path', - 'snippets', - 'lazydev', - }, - providers = { - lazydev = { - module = 'lazydev.integrations.blink', - score_offset = 100, + sources = { + default = { 'lsp', 'path', 'snippets', 'lazydev', 'copilot' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + copilot = { + name = 'copilot', + module = 'blink-cmp-copilot', + score_offset = 100, + async = true, + }, + }, }, + snippets = { preset = 'luasnip' }, + fuzzy = { implementation = 'prefer_rust_with_warning' }, + signature = { enabled = true }, }, }, - snippets = { preset = 'luasnip' }, - fuzzy = { implementation = 'prefer_rust_with_warning' }, - signature = { enabled = true }, } - -local function build_with_job(cmd, cwd, name) - vim.notify('Building ' .. name .. '...', vim.log.levels.INFO) - - vim.fn.jobstart(cmd, { - cwd = cwd, - on_exit = function(_, code) - if code == 0 then - vim.notify(name .. ' build completed successfully!', vim.log.levels.INFO) - else - vim.notify(name .. ' build failed with code ' .. code, vim.log.levels.ERROR) - end - end, - on_stdout = function(_, data) - if data and #data > 0 and data[1] ~= '' then - vim.notify(name .. ': ' .. table.concat(data, '\n'), vim.log.levels.DEBUG) - end - end, - }) -end - -vim.api.nvim_create_user_command('BlinkBuild', function() - local blink_path = vim.fn.stdpath 'data' .. '/site/pack/core/opt/blink.cmp' - build_with_job({ 'cargo', '+nightly', 'build', '--release' }, blink_path, 'blink.cmp') -end, { desc = 'Build blink.cmp' }) - -vim.api.nvim_create_autocmd('PackChanged', { - callback = function(args) - local spec = args.data.spec - if spec and spec.name == 'blink.cmp' and args.data.kind == 'update' then - vim.schedule(function() - vim.cmd 'BlinkBuild' - end) - end - end, -}) - -vim.api.nvim_create_user_command('LuaSnipBuild', function() - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - vim.notify 'LuaSnip build not supported on this system' - return - end - local luasnip_path = vim.fn.stdpath 'data' .. '/site/pack/core/opt/LuaSnip' - build_with_job({ 'make', 'install_jsregexp' }, luasnip_path, 'LuaSnip') -end, { desc = 'Build LuaSnip jsregexp' }) - -vim.api.nvim_create_autocmd('PackChanged', { - callback = function(args) - local spec = args.data.spec - if spec and spec.name == 'blink.cmp' and args.data.kind == 'update' then - vim.schedule(function() - vim.cmd 'LuaSnipBuild' - end) - end - end, -}) diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/colorizer.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/colorizer.lua new file mode 100644 index 0000000..199c59e --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/colorizer.lua @@ -0,0 +1,6 @@ +return { + { + 'norcalli/nvim-colorizer.lua', + opts = {}, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/colorschemes.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/colorschemes.lua index c8a9850..8e4a07a 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/colorschemes.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/colorschemes.lua @@ -1,13 +1,14 @@ -vim.pack.add { +return { { - name = 'tokyonight', - src = 'https://github.com/folke/tokyonight.nvim', + 'folke/tokyonight.nvim', + priority = 1000, + config = function() + require('tokyonight').setup { + styles = { + comments = { italic = false }, + }, + } + vim.cmd.colorscheme 'tokyonight' + end, }, } - -require('tokyonight').setup { - styles = { - comments = { italic = false }, - }, -} -vim.cmd.colorscheme 'tokyonight' diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/conform.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/conform.lua index d177759..f2a62be 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/conform.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/conform.lua @@ -1,95 +1,114 @@ -vim.pack.add({ +return { { - name = 'conform', - src = 'https://github.com/stevearc/conform.nvim', - }, -}, { load = false }) - -vim.api.nvim_create_autocmd('VimEnter', { - once = true, - callback = function() - local prettier_fmt = { 'prettierd', 'prettier', stop_after_first = true } - require('conform').setup { - notify_on_error = true, + 'https://github.com/stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + lazy = false, + keys = { + { + '<leader>f', + function() + require('conform').format { async = true, lsp_format = 'fallback' } + end, + mode = '', + desc = '[F]ormat buffer', + }, + { + '<leader>tf', + function() + -- If autoformat is currently disabled for this buffer, + -- then enable it, otherwise disable it + if vim.b.disable_autoformat then + vim.cmd 'FormatEnable' + vim.notify 'Enabled autoformat for current buffer' + else + vim.cmd 'FormatDisable!' + vim.notify 'Disabled autoformat for current buffer' + end + end, + desc = 'Toggle autoformat for current buffer', + }, + { + '<leader>tF', + function() + -- If autoformat is currently disabled globally, + -- then enable it globally, otherwise disable it globally + if vim.g.disable_autoformat then + vim.cmd 'FormatEnable' + vim.notify 'Enabled autoformat globally' + else + vim.cmd 'FormatDisable' + vim.notify 'Disabled autoformat globally' + end + end, + desc = 'Toggle autoformat globally', + }, + }, + opts = { + notify_on_error = false, format_on_save = function(bufnr) + -- Disable with a global or buffer-local variable if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end + + -- Disable "format_on_save lsp_fallback" for certain languages. + local disable_filetypes = { sql = true, c = true, cpp = true } + if disable_filetypes[vim.bo[bufnr].filetype] then + return nil + end + return { - timeout_ms = 500, + timeout_ms = 3000, lsp_format = 'fallback', } end, formatters_by_ft = { lua = { 'stylua' }, go = { 'goimports', 'gofmt' }, - python = { 'isort', 'black' }, + python = { 'black', 'isort' }, rust = { 'rustfmt' }, - javascript = prettier_fmt, - typescript = prettier_fmt, - javascriptreact = prettier_fmt, - typescriptreact = prettier_fmt, - css = prettier_fmt, - htmldjango = prettier_fmt, - html = prettier_fmt, sh = { 'shfmt' }, - cpp = { 'clang-format' }, - c = { 'clang-format' }, - tf = { 'terraformfmt' }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + typescript = { 'prettierd', 'prettier', stop_after_first = true }, + javascriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + typescriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + css = { 'prettierd', 'prettier', stop_after_first = true }, + htmldjango = { 'prettierd', 'prettier', stop_after_first = true }, + html = { 'prettierd', 'prettier', stop_after_first = true }, + tf = { 'terraform_fmt' }, }, formatters = { isort = { prepend_args = { '--profile', 'black' }, }, + shfmt = { + args = { '-i', '2' }, + }, }, - } - end, -}) - --- Format current buffer -vim.keymap.set({ 'n', 'v' }, '<leader>f', function() - require('conform').format { async = true, lsp_format = 'fallback' } -end, { desc = '[F]ormat buffer' }) - --- Toggle autoformat for current buffer -vim.keymap.set('n', '<leader>tf', function() - if vim.b.disable_autoformat then - vim.cmd 'FormatEnable' - vim.notify 'Enabled autoformat for current buffer' - else - vim.cmd 'FormatDisable!' - vim.notify 'Disabled autoformat for current buffer' - end -end, { desc = 'Toggle autoformat for current buffer' }) + }, + config = function(_, opts) + require('conform').setup(opts) --- Toggle autoformat globally -vim.keymap.set('n', '<leader>tF', function() - if vim.g.disable_autoformat then - vim.cmd 'FormatEnable' - vim.notify 'Enabled autoformat globally' - else - vim.cmd 'FormatDisable' - vim.notify 'Disabled autoformat globally' - end -end, { desc = 'Toggle autoformat globally' }) - --- :FormatDisable! disables autoformat for this buffer only --- :FormatDisable disables autoformat globally -vim.api.nvim_create_user_command('FormatDisable', function(args) - if args.bang then - vim.b.disable_autoformat = true - else - vim.g.disable_autoformat = true - end -end, { - desc = 'Disable autoformat-on-save', - bang = true, -}) + vim.api.nvim_create_user_command('FormatDisable', function(args) + if args.bang then + -- :FormatDisable! disables autoformat for this buffer only + vim.b.disable_autoformat = true + else + -- :FormatDisable disables autoformat globally + vim.g.disable_autoformat = true + end + end, { + desc = 'Disable autoformat-on-save', + bang = true, -- allows the ! variant + }) --- :FormatEnable enables autoformat globally and for this buffer -vim.api.nvim_create_user_command('FormatEnable', function() - vim.b.disable_autoformat = false - vim.g.disable_autoformat = false -end, { - desc = 'Re-enable autoformat-on-save', -}) + vim.api.nvim_create_user_command('FormatEnable', function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false + end, { + desc = 'Re-enable autoformat-on-save', + }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/fzf-lua.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/fzf-lua.lua deleted file mode 100644 index 0b7029d..0000000 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/fzf-lua.lua +++ /dev/null @@ -1,30 +0,0 @@ -vim.pack.add({ - { - name = 'fzf-lua', - src = 'https://github.com/ibhagwan/fzf-lua', - }, - { - name = 'nvim-web-devicons', - src = 'https://github.com/nvim-tree/nvim-web-devicons', - }, -}, { load = false }) - -vim.api.nvim_create_autocmd('VimEnter', { - once = true, - callback = function() - require('fzf-lua').setup {} - vim.keymap.set('n', '<leader>sh', require('fzf-lua').help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', '<leader>sk', require('fzf-lua').keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', '<leader>sf', require('fzf-lua').files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', '<leader>ss', require('fzf-lua').builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', '<leader>sw', require('fzf-lua').grep_cword, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', '<leader>sg', require('fzf-lua').live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', '<leader>sd', require('fzf-lua').diagnostics_document, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', '<leader>sr', require('fzf-lua').resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', '<leader>s.', require('fzf-lua').oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '<leader><leader>', require('fzf-lua').buffers, { desc = '[ ] Find existing buffers' }) - vim.keymap.set('n', '<leader>sn', function() - require('fzf-lua').files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, -}) diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/gitsigns.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/gitsigns.lua index a3fd83a..341b947 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/gitsigns.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/gitsigns.lua @@ -1,66 +1,64 @@ -vim.pack.add { +return { { - name = 'gitsigns', - src = 'https://github.com/lewis6991/gitsigns.nvim', - }, -} + 'https://github.com/lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + local gitsigns = require 'gitsigns' -require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - local gitsigns = require 'gitsigns' + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal { ']c', bang = true } + else + gitsigns.nav_hunk 'next' + end + end, { desc = 'Jump to next git [c]hange' }) - -- Navigation - map('n', ']c', function() - if vim.wo.diff then - vim.cmd.normal { ']c', bang = true } - else - gitsigns.nav_hunk 'next' - end - end, { desc = 'Jump to next git [c]hange' }) + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal { '[c', bang = true } + else + gitsigns.nav_hunk 'prev' + end + end, { desc = 'Jump to previous git [c]hange' }) - map('n', '[c', function() - if vim.wo.diff then - vim.cmd.normal { '[c', bang = true } - else - gitsigns.nav_hunk 'prev' - end - end, { desc = 'Jump to previous git [c]hange' }) - - -- Actions - -- visual mode - map('v', '<leader>hs', function() - gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'git [s]tage hunk' }) - map('v', '<leader>hr', function() - gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'git [r]eset hunk' }) - -- normal mode - map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', '<leader>hD', function() - gitsigns.diffthis '@' - end, { desc = 'git [D]iff against last commit' }) - -- Toggles - map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', '<leader>tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) - end, + -- Actions + -- visual mode + map('v', '<leader>hs', function() + gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'git [s]tage hunk' }) + map('v', '<leader>hr', function() + gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'git [r]eset hunk' }) + -- normal mode + map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', '<leader>hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) + map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', '<leader>hD', function() + gitsigns.diffthis '@' + end, { desc = 'git [D]iff against last commit' }) + -- Toggles + map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', '<leader>tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) + end, + }, + }, } diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/harpoon.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/harpoon.lua index 6d3b050..bb2dad2 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/harpoon.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/harpoon.lua @@ -1,18 +1,8 @@ -vim.pack.add({ - { - name = 'harpoon', - src = 'https://github.com/ThePrimeagen/harpoon', - version = 'harpoon2', - }, - { - name = 'plenary', - src = 'https://github.com/nvim-lua/plenary.nvim', - }, -}, { load = false }) - -vim.api.nvim_create_autocmd('VimEnter', { - once = true, - callback = function() +return { + 'https://github.com/ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'https://github.com/nvim-lua/plenary.nvim' }, + config = function() local harpoon = require 'harpoon' harpoon:setup() @@ -36,6 +26,10 @@ vim.api.nvim_create_autocmd('VimEnter', { harpoon:list():select(4) end) + vim.keymap.set('n', '<C-x>', function() + harpoon:list():clear() + end, { desc = 'Clear Harpoon list' }) + vim.keymap.set('n', '<leader>hp', function() harpoon:list():prev() end) @@ -43,4 +37,4 @@ vim.api.nvim_create_autocmd('VimEnter', { harpoon:list():next() end) end, -}) +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/indent_line.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/indent_line.lua index f6c0e8f..c098a80 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/indent_line.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/indent_line.lua @@ -1,8 +1,7 @@ -vim.pack.add { +return { { - name = 'indent-blankline', - src = 'https://github.com/lukas-reineke/indent-blankline.nvim', + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + opts = {}, }, } - -require('ibl').setup() diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/init.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/init.lua deleted file mode 100644 index f148112..0000000 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/init.lua +++ /dev/null @@ -1,20 +0,0 @@ -local plugins = { - 'tree-sitter', - 'colorschemes', - 'which-key', - 'indent_line', - 'conform', - 'fzf-lua', - 'gitsigns', - 'harpoon', - 'lint', - 'mini', - 'oil', - 'lsp', - 'blink', - 'tmux-navigator', -} - -for _, plugin in ipairs(plugins) do - pcall(require, 'eugenetriguba.plugins.' .. plugin) -end diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lazygit.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lazygit.lua new file mode 100644 index 0000000..17cb1c2 --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/lazygit.lua @@ -0,0 +1,17 @@ +return { + 'https://github.com/kdheepak/lazygit.nvim', + lazy = true, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + dependencies = { + 'https://github.com/nvim-lua/plenary.nvim', + }, + keys = { + { '<leader>lg', '<cmd>LazyGit<cr>', desc = 'LazyGit' }, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lint.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lint.lua index 72f9a51..eb152ec 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/lint.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/lint.lua @@ -1,52 +1,49 @@ -vim.pack.add({ +return { { - name = 'nvim-lint', - src = 'https://github.com/mfussenegger/nvim-lint', - }, -}, { load = false }) - -vim.api.nvim_create_autocmd({ 'BufReadPre', 'BufNewFile' }, { - callback = function() - -- Default linters, which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- They can be disabled by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil + 'https://github.com/mfussenegger/nvim-lint', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + -- Default linters, which will cause errors unless these tools are available: + -- { + -- clojure = { "clj-kondo" }, + -- dockerfile = { "hadolint" }, + -- inko = { "inko" }, + -- janet = { "janet" }, + -- json = { "jsonlint" }, + -- markdown = { "vale" }, + -- rst = { "vale" }, + -- ruby = { "ruby" }, + -- terraform = { "tflint" }, + -- text = { "vale" } + -- } + -- + -- They can be disabled by setting their filetypes to nil: + -- lint.linters_by_ft['clojure'] = nil - local lint = require 'lint' - lint.linters_by_ft = lint.linters_by_ft or {} - lint.linters_by_ft['cpp'] = { 'cppcheck' } - lint.linters_by_ft['dockerfile'] = { 'hadolint' } - lint.linters_by_ft['json'] = { 'jsonlint' } - lint.linters_by_ft['terraform'] = { 'tflint', 'terraform_validate' } - lint.linters_by_ft['python'] = { 'ruff', 'bandit' } - lint.linters_by_ft['markdown'] = nil - lint.linters_by_ft['text'] = nil - lint.linters_by_ft['sh'] = { 'shellcheck' } - lint.linters.shellcheck.args = { '-x' } + local lint = require 'lint' + lint.linters_by_ft = lint.linters_by_ft or {} + lint.linters_by_ft['cpp'] = { 'cppcheck' } + lint.linters_by_ft['dockerfile'] = { 'hadolint' } + lint.linters_by_ft['json'] = { 'jsonlint' } + lint.linters_by_ft['terraform'] = { 'tflint', 'terraform_validate' } + lint.linters_by_ft['python'] = { 'ruff', 'bandit' } + lint.linters_by_ft['markdown'] = nil + lint.linters_by_ft['text'] = nil + lint.linters_by_ft['sh'] = { 'shellcheck' } + lint.linters.shellcheck.args = { '-x' } - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - -- Only run the linter in buffers that you can modify in order to - -- avoid superfluous noise, notably within the handy LSP pop-ups that - -- describe the hovered symbol using Markdown. - if vim.opt_local.modifiable:get() then - lint.try_lint() - end - end, - }) - end, -}) + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { + group = lint_augroup, + callback = function() + -- Only run the linter in buffers that you can modify in order to + -- avoid superfluous noise, notably within the handy LSP pop-ups that + -- describe the hovered symbol using Markdown. + if vim.opt_local.modifiable:get() then + lint.try_lint() + end + end, + }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp.lua new file mode 100644 index 0000000..55794ff --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp.lua @@ -0,0 +1,152 @@ +return { + { + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + }, + }, + }, + { + 'neovim/nvim-lspconfig', + dependencies = { + { 'williamboman/mason.nvim', opts = {} }, + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + { 'j-hui/fidget.nvim', opts = {} }, + 'saghen/blink.cmp', + }, + config = function() + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + map('grn', vim.lsp.buf.rename, '[R]e[n]ame') + map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) + map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then + local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'lsp-highlight', buffer = event2.buf } + end, + }) + end + + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then + map('<leader>th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + vim.diagnostic.config { + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = vim.g.have_nerd_font and { + text = { + [vim.diagnostic.severity.ERROR] = ' ', + [vim.diagnostic.severity.WARN] = ' ', + [vim.diagnostic.severity.INFO] = ' ', + [vim.diagnostic.severity.HINT] = ' ', + }, + } or {}, + virtual_text = { + source = 'if_many', + spacing = 2, + format = function(diagnostic) + local diagnostic_message = { + [vim.diagnostic.severity.ERROR] = diagnostic.message, + [vim.diagnostic.severity.WARN] = diagnostic.message, + [vim.diagnostic.severity.INFO] = diagnostic.message, + [vim.diagnostic.severity.HINT] = diagnostic.message, + } + return diagnostic_message[diagnostic.severity] + end, + }, + } + + local capabilities = require('blink.cmp').get_lsp_capabilities() + local servers = { + clangd = {}, + gopls = {}, + pyright = { + settings = { + python = { + analysis = { + autoImportCompletions = true, + }, + }, + }, + }, + rust_analyzer = {}, + -- NOTE: https://github.com/pmizio/typescript-tools.nvim may be a better + -- LSP to use here at some point. + ts_ls = {}, + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + }, + }, + }, + stylua = {}, + tailwindcss = {}, + mesonlsp = {}, + terraformls = {}, + } + + local ensure_installed = vim.tbl_keys(servers or {}) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + require('mason-lspconfig').setup { + ensure_installed = {}, + automatic_installation = false, + automatic_enable = true, + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/diagnostics.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/diagnostics.lua deleted file mode 100644 index 4ea0673..0000000 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/diagnostics.lua +++ /dev/null @@ -1,27 +0,0 @@ --- See :help vim.diagnostic.Opts -vim.diagnostic.config { - severity_sort = true, - float = { border = 'rounded', source = 'if_many' }, - underline = { severity = vim.diagnostic.severity.ERROR }, - signs = vim.g.have_nerd_font and { - text = { - [vim.diagnostic.severity.ERROR] = ' ', - [vim.diagnostic.severity.WARN] = ' ', - [vim.diagnostic.severity.INFO] = ' ', - [vim.diagnostic.severity.HINT] = ' ', - }, - } or {}, - virtual_text = { - source = 'if_many', - spacing = 2, - format = function(diagnostic) - local diagnostic_message = { - [vim.diagnostic.severity.ERROR] = diagnostic.message, - [vim.diagnostic.severity.WARN] = diagnostic.message, - [vim.diagnostic.severity.INFO] = diagnostic.message, - [vim.diagnostic.severity.HINT] = diagnostic.message, - } - return diagnostic_message[diagnostic.severity] - end, - }, -} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/init.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/init.lua deleted file mode 100644 index 065f34c..0000000 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -require 'eugenetriguba.plugins.lsp.lspconfig' -require 'eugenetriguba.plugins.lsp.diagnostics' -require 'eugenetriguba.plugins.lsp.mason' diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/lspconfig.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/lspconfig.lua deleted file mode 100644 index 2ce6198..0000000 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/lspconfig.lua +++ /dev/null @@ -1,71 +0,0 @@ -vim.pack.add { - { - name = 'nvim-lspconfig', - src = 'https://github.com/neovim/nvim-lspconfig', - }, - { - name = 'fidget.nvim', - src = 'https://github.com/j-hui/fidget.nvim', - }, -} - -require('fidget').setup {} - -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), - callback = function(event) - -- Utility to more easily define mappings specific for LSP related items. - -- It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - map('grr', require('fzf-lua').lsp_references, '[G]oto [R]eferences') - map('gri', require('fzf-lua').lsp_implementations, '[G]oto [I]mplementation') - map('grd', require('fzf-lua').lsp_definitions, '[G]oto [D]efinition') - map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - map('gO', require('fzf-lua').lsp_document_symbols, 'Open Document Symbols') - map('gW', require('fzf-lua').lsp_workspace_symbols, 'Open Workspace Symbols') - map('grt', require('fzf-lua').lsp_typedefs, '[G]oto [T]ype Definition') - - -- Highlight references of the word under your cursor when your cursor - -- rests there for a little while. - -- - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then - local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- Keymap to toggle inlay hints if the language server supports them - if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then - map('<leader>th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end - end, -}) diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/mason.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/mason.lua deleted file mode 100644 index 2c2bde1..0000000 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/lsp/mason.lua +++ /dev/null @@ -1,62 +0,0 @@ -vim.pack.add { - { - name = 'mason.nvim', - src = 'https://github.com/williamboman/mason.nvim', - }, - { - name = 'mason-lspconfig.nvim', - src = 'https://github.com/williamboman/mason-lspconfig.nvim', - }, - { - name = 'mason-tool-installer.nvim', - src = 'https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim', - }, - { - name = 'blink.cmp', - src = 'https://github.com/saghen/blink.cmp', - }, -} - -require('mason').setup {} - -local capabilities = require('blink.cmp').get_lsp_capabilities() -local servers = { - clangd = {}, - gopls = {}, - pyright = {}, - rust_analyzer = {}, - -- Note: https://github.com/pmizio/typescript-tools.nvim may be a better - -- LSP to use here at some point. - ts_ls = {}, - lua_ls = { - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - }, - }, - }, - tailwindcss = {}, - mesonlsp = {}, - terraformls = {}, -} - -local ensure_installed = vim.tbl_keys(servers or {}) -vim.list_extend(ensure_installed, { - 'stylua', -- Used to format Lua code -}) -require('mason-tool-installer').setup { ensure_installed = ensure_installed } - -require('mason-lspconfig').setup { - ensure_installed = {}, -- Populated via mason-tool-installer - automatic_installation = false, - automatic_enable = true, - handlers = { - function(server_name) - local server = servers[server_name] or {} - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, -} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/lualine.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/lualine.lua new file mode 100644 index 0000000..d7b5c70 --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/lualine.lua @@ -0,0 +1,14 @@ +return { + { + 'https://github.com/nvim-lualine/lualine.nvim', + event = 'VeryLazy', + dependencies = { 'https://github.com/nvim-tree/nvim-web-devicons' }, + opts = { + options = { + theme = 'tokyonight', + component_separators = { left = '|', right = '|' }, + section_separators = { left = '', right = '' }, + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/mini.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/mini.lua index d00b8de..af67bcc 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/mini.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/mini.lua @@ -1,34 +1,24 @@ -vim.pack.add { +return { { - name = 'mini', - src = 'https://github.com/echasnovski/mini.nvim', + 'https://github.com/echasnovski/mini.nvim', + config = function() + require('mini.pairs').setup() + require('mini.git').setup() + require('mini.tabline').setup() + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yinq - [Y]ank [I]nside [N]ext [Q]uote + -- - ci' - [C]hange [I]nside [']quote + require('mini.ai').setup { n_lines = 500 } + + -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- + -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - sd' - [S]urround [D]elete [']quotes + -- - sr)' - [S]urround [R]eplace [)] ['] + -- require('mini.surround').setup() + end, }, } - -require('mini.pairs').setup() -require('mini.git').setup() -require('mini.tabline').setup() - --- Better Around/Inside textobjects --- --- Examples: --- - va) - [V]isually select [A]round [)]paren --- - yinq - [Y]ank [I]nside [N]ext [Q]uote --- - ci' - [C]hange [I]nside [']quote -require('mini.ai').setup { n_lines = 500 } - --- Add/delete/replace surroundings (brackets, quotes, etc.) --- --- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren --- - sd' - [S]urround [D]elete [']quotes --- - sr)' - [S]urround [R]eplace [)] ['] --- require('mini.surround').setup() - -local statusline = require 'mini.statusline' -statusline.setup { use_icons = true } - --- Set the section for cursor location to LINE:COLUMN ----@diagnostic disable-next-line: duplicate-set-field -statusline.section_location = function() - return '%2l:%-2v' -end diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/oil.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/oil.lua index e7d39c6..11c4981 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/oil.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/oil.lua @@ -1,18 +1,13 @@ -vim.pack.add { - { - name = 'oil', - src = 'https://github.com/stevearc/oil.nvim', - }, - { - name = 'mini.icons', - src = 'https://github.com/echasnovski/mini.icons', - }, +return { + 'https://github.com/stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + dependencies = { { 'https://github.com/echasnovski/mini.icons', opts = {} } }, + config = function(_, opts) + vim.keymap.set('n', '\\', '<CMD>Oil --float<CR>', { desc = 'Open parent directory in floating window' }) + vim.keymap.set('n', '-', '<CMD>Oil<CR>', { desc = 'Open parent directory' }) + require('oil').setup(opts) + end, + lazy = false, } - -require('oil').setup { - keymaps = { - ['<C-l>'] = false, -- Clashes with tmux navigator - }, -} -vim.keymap.set('n', '\\', '<CMD>Oil --float<CR>', { desc = 'Open parent directory in floating window' }) -vim.keymap.set('n', '-', '<CMD>Oil<CR>', { desc = 'Open parent directory' }) diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/telescope.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/telescope.lua new file mode 100644 index 0000000..8072b95 --- /dev/null +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/telescope.lua @@ -0,0 +1,80 @@ +return { + { + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + require('telescope').setup { + defaults = { + vimgrep_arguments = { + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--hidden', + '--glob', + '!.git/*', + }, + }, + pickers = { + find_files = { + find_command = { 'fd', '--type', 'f', '--hidden', '--strip-cwd-prefix', '--exclude', '.git' }, + }, + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + local builtin = require 'telescope.builtin' + vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', '<leader>sc', builtin.commands, { desc = '[S]earch [C]ommands' }) + vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + vim.keymap.set('n', '<leader>/', function() + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + vim.keymap.set('n', '<leader>s/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + vim.keymap.set('n', '<leader>sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/tmux-navigator.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/tmux-navigator.lua index 2ec0035..a92a2f7 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/tmux-navigator.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/tmux-navigator.lua @@ -1,6 +1,18 @@ -vim.pack.add { - { - name = 'vim-tmux-navigator', - src = 'https://github.com/christoomey/vim-tmux-navigator', +return { + 'https://github.com/christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + 'TmuxNavigatorProcessList', + }, + keys = { + { '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' }, + { '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' }, + { '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' }, + { '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' }, + { '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' }, }, } diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua index 07c8157..c89d962 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua @@ -1,39 +1,24 @@ -vim.pack.add { +return { { - name = 'nvim-treesitter', - src = 'https://github.com/nvim-treesitter/nvim-treesitter', + 'https://github.com/nvim-treesitter/nvim-treesitter', version = 'main', + main = 'nvim-treesitter.configs', + build = ':TSUpdate', + opts = { + ensure_installed = 'all', + auto_install = true, + ignore_install = { 'norg', 'org', 'ipkg' }, -- Issues installing them, unused anyway. + highlight = { + enable = true, + additional_vim_regex_highlighting = { 'ruby', 'cpp' }, + }, + indent = { enable = true, disable = { 'ruby', 'cpp' } }, + incremental_selection = { enable = true }, + context_commentstring = { enable = true }, + textobjects = { enable = true }, + }, }, { - name = 'nvim-treesitter-context', - src = 'https://github.com/nvim-treesitter/nvim-treesitter-context', + 'https://github.com/nvim-treesitter/nvim-treesitter-context', }, } - -require('nvim-treesitter.configs').setup { - ensure_installed = 'all', - auto_install = true, - modules = {}, - sync_install = false, - ignore_install = { 'norg', 'org', 'ipkg' }, -- Issues installing them, unused anyway. - highlight = { - enable = true, - additional_vim_regex_highlighting = { 'ruby', 'cpp' }, - }, - indent = { enable = true, disable = { 'ruby', 'cpp' } }, - incremental_selection = { enable = true }, - context_commentstring = { enable = true }, - textobjects = { enable = true }, -} - -local nts = require 'nvim-treesitter' -vim.api.nvim_create_autocmd('PackChanged', { - callback = function(args) - local spec = args.data.spec - if spec and spec.name == 'nvim-treesitter' and args.data.kind == 'update' then - vim.schedule(function() - nts.update() - end) - end - end, -}) diff --git a/nvim/.config/nvim/lua/eugenetriguba/plugins/which-key.lua b/nvim/.config/nvim/lua/eugenetriguba/plugins/which-key.lua index 47c789d..28c73d7 100644 --- a/nvim/.config/nvim/lua/eugenetriguba/plugins/which-key.lua +++ b/nvim/.config/nvim/lua/eugenetriguba/plugins/which-key.lua @@ -1,13 +1,6 @@ -vim.pack.add({ +return { { - name = 'which-key', - src = 'https://github.com/folke/which-key.nvim', + 'https://github.com/folke/which-key.nvim', + event = 'VimEnter', }, -}, { load = false }) - -vim.api.nvim_create_autocmd('VimEnter', { - once = true, - callback = function() - require('which-key').setup {} - end, -}) +} diff --git a/nvim/.config/nvim/spell/en.utf-8.add.spl b/nvim/.config/nvim/spell/en.utf-8.add.spl Binary files differnew file mode 100644 index 0000000..c296281 --- /dev/null +++ b/nvim/.config/nvim/spell/en.utf-8.add.spl |