From c55bdc3d2c2c2cc93c6edebf24d2b92f47f153c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Uruba?= Date: Wed, 5 Feb 2025 17:10:17 +0100 Subject: [PATCH] update nvim config (IDE setup) --- nvim/.config/nvim/lazy-lock.json | 50 +++++---- nvim/.config/nvim/lua/core/options.lua | 2 +- nvim/.config/nvim/lua/core/theme.lua | 2 +- .../nvim/lua/lazy-plugins/base-plenary.lua | 2 +- .../nvim/lua/lazy-plugins/code-mason.lua | 4 - .../lua/lazy-plugins/editor-autopairs.lua | 31 ++++- .../lua/lazy-plugins/editor-comment-todo.lua | 21 ++++ .../nvim/lua/lazy-plugins/editor-comment.lua | 18 +++ .../{css-color.lua => editor-css-color.lua} | 0 .../lua/lazy-plugins/editor-git-lazygit.lua | 19 ++++ .../lua/lazy-plugins/editor-git-signs.lua | 49 +++++++- .../lua/lazy-plugins/editor-substitute.lua | 17 +++ .../nvim/lua/lazy-plugins/editor-surround.lua | 5 +- .../nvim/lua/lazy-plugins/feat-rest-nvim.lua | 16 +-- .../nvim/lua/lazy-plugins/lsp-formatting.lua | 37 ++++++ .../nvim/lua/lazy-plugins/lsp-linting.lua | 27 +++++ .../nvim/lua/lazy-plugins/lsp-lspconfig.lua | 106 ++++++++++++++++++ .../nvim/lua/lazy-plugins/lsp-mason.lua | 49 ++++++++ .../nvim/lua/lazy-plugins/lsp-nvim-cmp.lua | 2 - .../nvim/lua/lazy-plugins/lsp-trouble.lua | 15 +++ .../nvim/lua/lazy-plugins/ui-alpha.lua | 38 +++---- .../nvim/lua/lazy-plugins/ui-barbar.lua | 6 +- .../nvim/lua/lazy-plugins/ui-nvim-tree.lua | 10 +- .../nvim/lua/lazy-plugins/ui-tagbar.lua | 2 +- .../nvim/lua/lazy-plugins/ui-telescope.lua | 5 + .../nvim/lua/lazy-plugins/ui-which-key.lua | 8 +- 26 files changed, 465 insertions(+), 76 deletions(-) delete mode 100644 nvim/.config/nvim/lua/lazy-plugins/code-mason.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/editor-comment-todo.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/editor-comment.lua rename nvim/.config/nvim/lua/lazy-plugins/{css-color.lua => editor-css-color.lua} (100%) create mode 100644 nvim/.config/nvim/lua/lazy-plugins/editor-git-lazygit.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/editor-substitute.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/lsp-formatting.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/lsp-linting.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/lsp-lspconfig.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/lsp-mason.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/lsp-trouble.lua diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index a76b7ea..8f1ff1c 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,36 +1,48 @@ { + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, - "auto-session": { "branch": "main", "commit": "021b64ed7d4ac68a37be3ad28d8e1cba5bec582c" }, - "barbar.nvim": { "branch": "master", "commit": "a26bae6c51899db530de19ce3c2f4307e37a869e" }, - "bufferline.nvim": { "branch": "main", "commit": "5726c4e291224181903e960119a11e20ac677a0a" }, + "auto-session": { "branch": "main", "commit": "82630e2f70be140f8dcc75a12e2ee2839e8488c2" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, + "dressing.nvim": { "branch": "master", "commit": "56ef6a969a4990d938c5fed40c370f65e125fc97" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "gitsigns.nvim": { "branch": "main", "commit": "9b36d497495436c135659902054ee637e0ba6021" }, "hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" }, - "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, - "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" }, + "lazy.nvim": { "branch": "main", "commit": "7527af40ddd4a93a02911be570b32609b9d4ea53" }, + "lazygit.nvim": { "branch": "main", "commit": "adc37c5a6d7d6e8d0a039f08f3c7837971a1c77a" }, "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "374c78d3ebb5c53f43ea6bd906b6587b5e899b9e" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "f968becf44b05d8c54d4fa95c9ca699df4de363b" }, - "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, - "nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" }, - "nvim-tree.lua": { "branch": "master", "commit": "68fc4c20f5803444277022c681785c5edd11916d" }, - "nvim-treesitter": { "branch": "master", "commit": "57713d079c3c2afcc31f3e0650bf8594a2a296ba" }, + "mini.nvim": { "branch": "main", "commit": "87fc38a8a2b8d498cecb021d057a38ea2e9f5a79" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "nvim-autopairs": { "branch": "master", "commit": "3d02855468f94bf435db41b661b58ec4f48a06b7" }, + "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, + "nvim-lint": { "branch": "master", "commit": "789b7ada1b4f00e08d026dffde410dcfa6a0ba87" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "66bc018936c6ff76beb75f89d986af6442db4001" }, + "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, + "nvim-tree.lua": { "branch": "master", "commit": "70825f23db61ecd900c4cfea169bffe931926a9d" }, + "nvim-treesitter": { "branch": "master", "commit": "53a6b3993f5803378d4d031bf114c0b125a52ba8" }, "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, - "nvim-web-devicons": { "branch": "master", "commit": "5740b7382429d20b6ed0bbdb0694185af9507d44" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, + "nvim-web-devicons": { "branch": "master", "commit": "402377242b04be3f4f0f3720bd952df86e946c30" }, "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, - "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "rest.nvim": { "branch": "main", "commit": "545509268d5e928d72d64764c21ef65c77e90edf" }, - "tagbar": { "branch": "master", "commit": "8de7694c0aeda253073098bbc9fb890b2902ddb8" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, + "rest.nvim": { "branch": "main", "commit": "62606c3599bd304227457d6e20580965939b191e" }, + "substitute.nvim": { "branch": "main", "commit": "97f49d16f8eea7967d41db4f657dd63af53eeba1" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, - "telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" }, + "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "trouble.nvim": { "branch": "main", "commit": "6f380b8826fb819c752c8fd7daaee9ef96d4c689" }, "vim-css-color": { "branch": "master", "commit": "14fd934cdd9ca1ac0e53511094e612eb9bace373" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" } + "which-key.nvim": { "branch": "main", "commit": "0e76a87ac51772569aec678dc74baa8e2a86100c" } } diff --git a/nvim/.config/nvim/lua/core/options.lua b/nvim/.config/nvim/lua/core/options.lua index d0bd5bf..dadd5a9 100644 --- a/nvim/.config/nvim/lua/core/options.lua +++ b/nvim/.config/nvim/lua/core/options.lua @@ -1 +1 @@ -vim.cmd("let g:netrw_liststyle = 3") +vim.cmd('let g:netrw_liststyle = 3') diff --git a/nvim/.config/nvim/lua/core/theme.lua b/nvim/.config/nvim/lua/core/theme.lua index 53db822..975b885 100644 --- a/nvim/.config/nvim/lua/core/theme.lua +++ b/nvim/.config/nvim/lua/core/theme.lua @@ -5,7 +5,7 @@ -- See: https://github.com/brainfucksec/neovim-lua#appearance -- Load nvim color scheme: --- Change the "require" values with your color scheme +-- Change the 'require' values with your color scheme local status_ok, color_scheme = pcall(require, 'onedark') if not status_ok then return diff --git a/nvim/.config/nvim/lua/lazy-plugins/base-plenary.lua b/nvim/.config/nvim/lua/lazy-plugins/base-plenary.lua index 5b8c0e9..55d3bd8 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/base-plenary.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/base-plenary.lua @@ -1,4 +1,4 @@ -- Plenary return { - "nvim-lua/plenary.nvim", + 'nvim-lua/plenary.nvim', } diff --git a/nvim/.config/nvim/lua/lazy-plugins/code-mason.lua b/nvim/.config/nvim/lua/lazy-plugins/code-mason.lua deleted file mode 100644 index 9541e85..0000000 --- a/nvim/.config/nvim/lua/lazy-plugins/code-mason.lua +++ /dev/null @@ -1,4 +0,0 @@ --- Plenary -return { - "williamboman/mason.nvim", -} diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-autopairs.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-autopairs.lua index f38f155..609c5cf 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/editor-autopairs.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-autopairs.lua @@ -1,6 +1,31 @@ -- Autopairs return { - "windwp/nvim-autopairs", - event = "InsertEnter", - opts = {}, + 'windwp/nvim-autopairs', + event = 'InsertEnter', + dependencies = { + 'hrsh7th/nvim-cmp', + }, + config = function() + -- import nvim-autopairs + local autopairs = require('nvim-autopairs') + + -- configure autopairs + autopairs.setup({ + check_ts = true, -- enable treesitter + ts_config = { + lua = { 'string' }, -- don't add pairs in lua string treesitter nodes + javascript = { 'template_string' }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, + }) + + -- import nvim-autopairs completion functionality + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + + -- import nvim-cmp plugin (completions plugin) + local cmp = require('cmp') + + -- make autopairs and completion work together + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, } diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-comment-todo.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-comment-todo.lua new file mode 100644 index 0000000..3309773 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-comment-todo.lua @@ -0,0 +1,21 @@ +return { + 'folke/todo-comments.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local todo_comments = require('todo-comments') + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set('n', ']t', function() + todo_comments.jump_next() + end, { desc = 'Next todo comment' }) + + keymap.set('n', '[t', function() + todo_comments.jump_prev() + end, { desc = 'Previous todo comment' }) + + todo_comments.setup() + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-comment.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-comment.lua new file mode 100644 index 0000000..2b03f55 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-comment.lua @@ -0,0 +1,18 @@ +return { + 'numToStr/Comment.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + 'JoosepAlviste/nvim-ts-context-commentstring', + }, + config = function() + -- import comment plugin safely + local comment = require('Comment') + local ts_context_commentstring = require('ts_context_commentstring.integrations.comment_nvim') + + -- enable comment + comment.setup({ + -- for commenting tsx, jsx, svelte, html files + pre_hook = ts_context_commentstring.create_pre_hook(), + }) + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/css-color.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-css-color.lua similarity index 100% rename from nvim/.config/nvim/lua/lazy-plugins/css-color.lua rename to nvim/.config/nvim/lua/lazy-plugins/editor-css-color.lua diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-git-lazygit.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-git-lazygit.lua new file mode 100644 index 0000000..6cf4a3a --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-git-lazygit.lua @@ -0,0 +1,19 @@ +return { + 'kdheepak/lazygit.nvim', + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { 'lg', 'LazyGit', desc = 'Open lazy git' }, + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-git-signs.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-git-signs.lua index 7052fcb..d314cc7 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/editor-git-signs.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-git-signs.lua @@ -1,7 +1,48 @@ -- Git signs return { - "lewis6991/gitsigns.nvim", - config = function () - require("gitsigns").setup() - end + 'lewis6991/gitsigns.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + opts = { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc }) + end + + -- Navigation + map('n', ']h', gs.next_hunk, 'Next Hunk') + map('n', '[h', gs.prev_hunk, 'Prev Hunk') + + -- Actions + map('n', 'hs', gs.stage_hunk, 'Stage hunk') + map('n', 'hr', gs.reset_hunk, 'Reset hunk') + map('v', 'hs', function() + gs.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end, 'Stage hunk') + map('v', 'hr', function() + gs.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end, 'Reset hunk') + + map('n', 'hS', gs.stage_buffer, 'Stage buffer') + map('n', 'hR', gs.reset_buffer, 'Reset buffer') + + map('n', 'hu', gs.undo_stage_hunk, 'Undo stage hunk') + + map('n', 'hp', gs.preview_hunk, 'Preview hunk') + + map('n', 'hb', function() + gs.blame_line({ full = true }) + end, 'Blame line') + map('n', 'hB', gs.toggle_current_line_blame, 'Toggle line blame') + + map('n', 'hd', gs.diffthis, 'Diff this') + map('n', 'hD', function() + gs.diffthis('~') + end, 'Diff this ~') + + -- Text object + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', 'Gitsigns select hunk') + end, + }, } diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-substitute.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-substitute.lua new file mode 100644 index 0000000..6c4cb36 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-substitute.lua @@ -0,0 +1,17 @@ +return { + 'gbprod/substitute.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + local substitute = require('substitute') + + substitute.setup() + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set('n', 's', substitute.operator, { desc = 'Substitute with motion' }) + keymap.set('n', 'ss', substitute.line, { desc = 'Substitute line' }) + keymap.set('n', 'S', substitute.eol, { desc = 'Substitute to end of line' }) + keymap.set('x', 's', substitute.visual, { desc = 'Substitute in visual mode' }) + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/editor-surround.lua b/nvim/.config/nvim/lua/lazy-plugins/editor-surround.lua index 98d8eb4..43cf984 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/editor-surround.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/editor-surround.lua @@ -1,4 +1,7 @@ -- Surround return { - "tpope/vim-surround", + 'kylechui/nvim-surround', + event = { 'BufReadPre', 'BufNewFile' }, + version = '*', -- Use for stability; omit to use `main` branch for the latest features + config = true, } diff --git a/nvim/.config/nvim/lua/lazy-plugins/feat-rest-nvim.lua b/nvim/.config/nvim/lua/lazy-plugins/feat-rest-nvim.lua index 4390ebe..3ffbf92 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/feat-rest-nvim.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/feat-rest-nvim.lua @@ -1,9 +1,9 @@ return { - "rest-nvim/rest.nvim", - dependencies = { { "nvim-lua/plenary.nvim" } }, - event = "BufEnter *.http", + 'rest-nvim/rest.nvim', + dependencies = { { 'nvim-lua/plenary.nvim' } }, + event = 'BufEnter *.http', config = function() - require("rest-nvim").setup({ + require('rest-nvim').setup({ -- Open request results in a horizontal split result_split_horizontal = false, -- Keep the http file buffer above|left when split horizontal|vertical @@ -33,9 +33,9 @@ return { -- executables or functions for formatting response body [optional] -- set them to false if you want to disable them formatters = { - json = "jq", + json = 'jq', html = function(body) - return vim.fn.system({"tidy", "-i", "-q", "-"}, body) + return vim.fn.system({'tidy', '-i', '-q', '-'}, body) end }, }, @@ -43,8 +43,8 @@ return { jump_to_request = false, env_file = '.env', -- for telescope select - env_pattern = "\\.env$", - env_edit_command = "tabedit", + env_pattern = '\\.env$', + env_edit_command = 'tabedit', custom_dynamic_variables = {}, yank_dry_run = true, search_back = true, diff --git a/nvim/.config/nvim/lua/lazy-plugins/lsp-formatting.lua b/nvim/.config/nvim/lua/lazy-plugins/lsp-formatting.lua new file mode 100644 index 0000000..bcb1bff --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/lsp-formatting.lua @@ -0,0 +1,37 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + local conform = require('conform') + + conform.setup({ + formatters_by_ft = { + javascript = { 'prettier' }, + typescript = { 'prettier' }, + svelte = { 'prettier' }, + css = { 'prettier' }, + html = { 'prettier' }, + json = { 'prettier' }, + yaml = { 'prettier' }, + markdown = { 'prettier' }, + graphql = { 'prettier' }, + liquid = { 'prettier' }, + lua = { 'stylua' }, + python = { 'isort', 'black' }, + }, + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }, + }) + + vim.keymap.set({ 'n', 'v' }, 'mp', function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }) + end, { desc = 'Format file or range (in visual mode)' }) + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/lsp-linting.lua b/nvim/.config/nvim/lua/lazy-plugins/lsp-linting.lua new file mode 100644 index 0000000..8836b18 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/lsp-linting.lua @@ -0,0 +1,27 @@ +return { + 'mfussenegger/nvim-lint', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + local lint = require('lint') + + lint.linters_by_ft = { + javascript = { 'eslint_d' }, + typescript = { 'eslint_d' }, + svelte = { 'eslint_d' }, + python = { 'pylint' }, + } + + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) + + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set('n', 'l', function() + lint.try_lint() + end, { desc = 'Trigger linting for current file' }) + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/lsp-lspconfig.lua b/nvim/.config/nvim/lua/lazy-plugins/lsp-lspconfig.lua new file mode 100644 index 0000000..b18784b --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/lsp-lspconfig.lua @@ -0,0 +1,106 @@ +return { + 'neovim/nvim-lspconfig', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + { 'antosha417/nvim-lsp-file-operations', config = true }, + { 'folke/neodev.nvim', opts = {} }, + }, + config = function() + -- import lspconfig plugin + local lspconfig = require('lspconfig') + + -- import mason_lspconfig plugin + local mason_lspconfig = require('mason-lspconfig') + + -- import cmp-nvim-lsp plugin + local cmp_nvim_lsp = require('cmp_nvim_lsp') + + local keymap = vim.keymap -- for conciseness + + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf, silent = true } + + -- set keybinds + opts.desc = 'Show LSP references' + keymap.set('n', 'gR', 'Telescope lsp_references', opts) -- show definition, references + + opts.desc = 'Go to declaration' + keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = 'Show LSP definitions' + keymap.set('n', 'gd', 'Telescope lsp_definitions', opts) -- show lsp definitions + + opts.desc = 'Show LSP implementations' + keymap.set('n', 'gi', 'Telescope lsp_implementations', opts) -- show lsp implementations + + opts.desc = 'Show LSP type definitions' + keymap.set('n', 'gt', 'Telescope lsp_type_definitions', opts) -- show lsp type definitions + + opts.desc = 'See available code actions' + keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = 'Smart rename' + keymap.set('n', 'rn', vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = 'Show buffer diagnostics' + keymap.set('n', 'D', 'Telescope diagnostics bufnr=0', opts) -- show diagnostics for file + + opts.desc = 'Show line diagnostics' + keymap.set('n', 'd', vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = 'Go to previous diagnostic' + keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = 'Go to next diagnostic' + keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + + opts.desc = 'Show documentation for what is under cursor' + keymap.set('n', 'K', vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = 'Restart LSP' + keymap.set('n', 'rs', ':LspRestart', opts) -- mapping to restart lsp if necessary + end, + }) + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = cmp_nvim_lsp.default_capabilities() + + -- Change the Diagnostic symbols in the sign column (gutter) + local signs = { Error = ' ', Warn = ' ', Hint = '󰠠 ', Info = ' ' } + for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) + end + + mason_lspconfig.setup_handlers({ + -- default handler for installed servers + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ['lua_ls'] = function() + -- configure lua server (with special settings) + lspconfig['lua_ls'].setup({ + capabilities = capabilities, + settings = { + Lua = { + -- make the language server recognize 'vim' global + diagnostics = { + globals = { 'vim' }, + }, + completion = { + callSnippet = 'Replace', + }, + }, + }, + }) + end, + }) + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/lsp-mason.lua b/nvim/.config/nvim/lua/lazy-plugins/lsp-mason.lua new file mode 100644 index 0000000..f4e6706 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/lsp-mason.lua @@ -0,0 +1,49 @@ +-- Plenary +return { + 'williamboman/mason.nvim', + dependencies = { + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + }, + config = function() + -- import mason + local mason = require('mason') + + -- import mason-lspconfig + local mason_lspconfig = require('mason-lspconfig') + + local mason_tool_installer = require('mason-tool-installer') + + -- enable mason and configure icons + mason.setup({ + ui = { + icons = { + package_installed = '✓', + package_pending = '➜', + package_uninstalled = '✗', + }, + }, + }) + + mason_lspconfig.setup({ + -- list of servers for mason to install + ensure_installed = { + 'html', + 'cssls', + 'svelte', + 'lua_ls', + }, + }) + + mason_tool_installer.setup({ + ensure_installed = { + 'prettier', -- prettier formatter + 'stylua', -- lua formatter + 'isort', -- python formatter + 'black', -- python formatter + 'pylint', + 'eslint_d', + }, + }) + end, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/lsp-nvim-cmp.lua b/nvim/.config/nvim/lua/lazy-plugins/lsp-nvim-cmp.lua index 3f8b2df..dd9045f 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/lsp-nvim-cmp.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/lsp-nvim-cmp.lua @@ -17,9 +17,7 @@ return { }, config = function() local cmp = require('cmp') - local luasnip = require('luasnip') - local lspkind = require('lspkind') -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) diff --git a/nvim/.config/nvim/lua/lazy-plugins/lsp-trouble.lua b/nvim/.config/nvim/lua/lazy-plugins/lsp-trouble.lua new file mode 100644 index 0000000..04efa22 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/lsp-trouble.lua @@ -0,0 +1,15 @@ +return { + 'folke/trouble.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons', 'folke/todo-comments.nvim' }, + opts = { + focus = true, + }, + cmd = 'Trouble', + keys = { + { 'xw', 'Trouble diagnostics toggle', desc = 'Open trouble workspace diagnostics' }, + { 'xd', 'Trouble diagnostics toggle filter.buf=0', desc = 'Open trouble document diagnostics' }, + { 'xq', 'Trouble quickfix toggle', desc = 'Open trouble quickfix list' }, + { 'xl', 'Trouble loclist toggle', desc = 'Open trouble location list' }, + { 'xt', 'Trouble todo toggle', desc = 'Open todos in trouble' }, + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/ui-alpha.lua b/nvim/.config/nvim/lua/lazy-plugins/ui-alpha.lua index f38a6e5..48ed730 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/ui-alpha.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/ui-alpha.lua @@ -1,32 +1,32 @@ -- Alpha (start screen/dashboard) return { - "goolord/alpha-nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - event = "VimEnter", + 'goolord/alpha-nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + event = 'VimEnter', config = function() - local alpha = require("alpha") - local dashboard = require("alpha.themes.dashboard") + local alpha = require('alpha') + local dashboard = require('alpha.themes.dashboard') -- Set header dashboard.section.header.val = { - " ", - " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", - " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", - " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ", - " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ", - " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", - " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", - " ", + ' ', + ' ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ', + ' ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ', + ' ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ', + ' ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ', + ' ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ', + ' ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ', + ' ', } -- Set menu dashboard.section.buttons.val = { - dashboard.button("e", " > New File", "ene"), - dashboard.button("SPC ee", " > Toggle file explorer", "NvimTreeToggle"), - dashboard.button("SPC ff", "󰱼 > Find File", "Telescope find_files"), - dashboard.button("SPC fs", " > Find Word", "Telescope live_grep"), - dashboard.button("SPC wr", "󰁯 > Restore Session For Current Directory", "SessionRestore"), - dashboard.button("q", " > Quit NVIM", "qa"), + dashboard.button('e', ' > New File', 'ene'), + dashboard.button('SPC ee', ' > Toggle file explorer', 'NvimTreeToggle'), + dashboard.button('SPC ff', '󰱼 > Find File', 'Telescope find_files'), + dashboard.button('SPC fs', ' > Find Word', 'Telescope live_grep'), + dashboard.button('SPC wr', '󰁯 > Restore Session For Current Directory', 'SessionRestore'), + dashboard.button('q', ' > Quit NVIM', 'qa'), } -- Send config to alpha diff --git a/nvim/.config/nvim/lua/lazy-plugins/ui-barbar.lua b/nvim/.config/nvim/lua/lazy-plugins/ui-barbar.lua index cdd1217..c296aa5 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/ui-barbar.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/ui-barbar.lua @@ -1,9 +1,9 @@ -- Barbar (tabline bar) return { - "romgrk/barbar.nvim", + 'romgrk/barbar.nvim', enabled = false, dependencies = { - "lewis6991/gitsigns.nvim", - "nvim-tree/nvim-web-devicons", + 'lewis6991/gitsigns.nvim', + 'nvim-tree/nvim-web-devicons', }, } diff --git a/nvim/.config/nvim/lua/lazy-plugins/ui-nvim-tree.lua b/nvim/.config/nvim/lua/lazy-plugins/ui-nvim-tree.lua index 3d36581..c5a2935 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/ui-nvim-tree.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/ui-nvim-tree.lua @@ -1,8 +1,8 @@ return { - "nvim-tree/nvim-tree.lua", - dependencies = "nvim-tree/nvim-web-devicons", + 'nvim-tree/nvim-tree.lua', + dependencies = 'nvim-tree/nvim-web-devicons', config = function() - local nvimtree = require('nvim-tree') + local nvimtree = require('nvim-tree') vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 @@ -19,8 +19,8 @@ return { icons = { glyphs = { folder = { - arrow_closed = "", -- arrow when folder is closed - arrow_open = "", -- arrow when folder is open + arrow_closed = '', -- arrow when folder is closed + arrow_open = '', -- arrow when folder is open }, }, }, diff --git a/nvim/.config/nvim/lua/lazy-plugins/ui-tagbar.lua b/nvim/.config/nvim/lua/lazy-plugins/ui-tagbar.lua index fc12c32..2f1ee7d 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/ui-tagbar.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/ui-tagbar.lua @@ -1,5 +1,5 @@ -- Tagbar return { - "preservim/tagbar", + 'preservim/tagbar', enabled = false, } diff --git a/nvim/.config/nvim/lua/lazy-plugins/ui-telescope.lua b/nvim/.config/nvim/lua/lazy-plugins/ui-telescope.lua index c611d5d..d32de02 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/ui-telescope.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/ui-telescope.lua @@ -56,5 +56,10 @@ return { 'Telescope grep_string', desc = 'Find string', }, + { + 'ft', + 'TodoTelescope', + desc = 'Find todos', + } }, } diff --git a/nvim/.config/nvim/lua/lazy-plugins/ui-which-key.lua b/nvim/.config/nvim/lua/lazy-plugins/ui-which-key.lua index 7731a10..57abfde 100644 --- a/nvim/.config/nvim/lua/lazy-plugins/ui-which-key.lua +++ b/nvim/.config/nvim/lua/lazy-plugins/ui-which-key.lua @@ -6,11 +6,11 @@ return { vim.o.timeoutlen = 500 end, config = function() - local wk = require("which-key") + local wk = require('which-key') wk.register({ - { "e", group = "NeoTree" }, - { "f", group = "Telescope" }, - { "s", group = "splits" }, + { 'e', group = 'NeoTree' }, + { 'f', group = 'Telescope' }, + { 's', group = 'splits' }, }) end, opts = { },