From f97d64c598e851329521cb29b2ed7f5f5c2a3334 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Fri, 15 Mar 2024 21:33:43 -0300 Subject: [PATCH] refactor: move config --- TODO.md | 5 ++- after/.gitkeep | 0 after/plugin/lsp.lua | 22 +++++++++- after/plugin/treesitter.lua | 81 +++++++++++++++++++++++++++++++++++ lazy-lock.json | 4 ++ lua/keymaps.lua | 2 + lua/pluginlist.lua | 85 +++++++++++++++++++++++++++++++------ 7 files changed, 184 insertions(+), 15 deletions(-) mode change 100644 => 100755 TODO.md create mode 100644 after/.gitkeep create mode 100644 after/plugin/treesitter.lua diff --git a/TODO.md b/TODO.md old mode 100644 new mode 100755 index 7049f7f..981fcac --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,9 @@ - [ ] (), {}, [] and closing tags auto competition -- [ ] Integration with lazygit or other git integration/TUI +- [x] Integration with lazygit or other git integration/TUI - [ ] Plugin for easily jumping in file, like leap.nvim or hop.nvim - [ ] Configure neo-tree mappings. -- [ ] Some type of spell checking? +- [x] Some type of spell checking? - [ ] Better markdown editing. +- [ ] Fix nix integration. diff --git a/after/.gitkeep b/after/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index fcd2121..187ebac 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -12,7 +12,7 @@ local on_attach = function(_, bufnr) bmap('gI', vim.lsp.buf.implementation, 'Goto Implementation'); bmap('D', vim.lsp.buf.type_definition, 'Type Definition'); - bmap('K', vim.lsp.buf.hover, 'Hover docs'); + -- bmap('K', vim.lsp.buf.hover, 'Hover docs'); bmap('', vim.lsp.buf.signature_help, 'Signature docs'); vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) @@ -36,6 +36,26 @@ require('which-key').register({ ['w'] = { name = '[w] Workspace', _ = 'which_key_ignore' }, }); +require('hover').setup({ + init = function() + require('hover.providers.lsp'); + end, + preview_opts = { + border = 'single', + }, + preview_window = false, + title = true, + mouse_providers = { 'LSP', }, + mouse_delay = 1000, +}); + +vim.keymap.set('n', 'K', require('hover').hover, { desc = '[K] Hover' }); +vim.keymap.set('n', 'sK', require('hover').hover_select, { desc = '[K] Hover select' }); + +-- Mouse support +vim.keymap.set('n', '', require('hover').hover_mouse, { desc = '[MouseMove] Hover mouse' }); +vim.o.mousemoveevent = true; + local capabilities = vim.lsp.protocol.make_client_capabilities(); capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities); diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..2390868 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,81 @@ +require('nvim-treesitter.configs').setup({ + ensure_installed = { 'lua', 'vim', 'vimdoc', 'bash', 'javascript' }, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false, + keybindings = { + toggle_query_editor = 'o', + toggle_hl_groups = 'i', + toggle_injected_languages = 't', + toggle_anonymous_nodes = 'a', + toggle_language_display = 'I', + focus_language = 'f', + unfocus_language = 'F', + update = 'R', + goto_node = '', + show_help = '?', + }, + }, + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { 'BugWrite', 'CursorHold' }, + }, +}); diff --git a/lazy-lock.json b/lazy-lock.json index 6d83072..9c60430 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -5,6 +5,8 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" }, + "gitsigns.nvim": { "branch": "main", "commit": "3e6e91b09f0468c32d3b96dcacf4b947f037ce25" }, + "hover.nvim": { "branch": "main", "commit": "bbd59ddfae4e64459944acf2abcda4d81ba8bac6" }, "indent-blankline.nvim": { "branch": "master", "commit": "3c8a185da4b8ab7aef487219f5e001b11d4b6aaf" }, "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, "lspkind.nvim": { "branch": "master", "commit": "7f26cf5e27e2bd910ce0ea00c514da2bf97423b8" }, @@ -14,7 +16,9 @@ "neodev.nvim": { "branch": "main", "commit": "be8d4d4cab6c13c6a572269c9d6a63774baba9a0" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" }, "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, + "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } diff --git a/lua/keymaps.lua b/lua/keymaps.lua index d383dd6..89add65 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -33,6 +33,8 @@ vim.keymap.set('n', 'x', '!chmod +x %', { silent = true }); vim.keymap.set('n', 'w\\', ':vsplit', { desc = '[w\\] Splits the window vertically' }); vim.keymap.set('n', 'w/', ':split', { desc = '[w/] Splits the window horizontally' }); +vim.keymap.set('n', 'e', ':Ex', { desc = '[e] Explorer' }); + vim.keymap.set('n', 's=', 'z=', { desc = '[s=] Suggest spelling correction' }); vim.keymap.set('n', 'st', function() if vim.o.spell then diff --git a/lua/pluginlist.lua b/lua/pluginlist.lua index d074b5f..585cad6 100644 --- a/lua/pluginlist.lua +++ b/lua/pluginlist.lua @@ -27,13 +27,6 @@ return { main = 'ibl', opts = {}, }, - { 'j-hui/fidget.nvim', }, - { "williamboman/mason.nvim", }, - { "williamboman/mason-lspconfig.nvim", }, - { "neovim/nvim-lspconfig", }, - { 'folke/which-key.nvim', }, - { 'folke/neodev.nvim', }, - { 'nvim-tree/nvim-web-devicons', }, { 'lewis6991/gitsigns.nvim', opts = { @@ -44,14 +37,15 @@ return { topdelete = { text = '-' }, changedelete = { text = '~' }, }, - on_attach = function (bufnr) - vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }); + on_attach = function(bufnr) + vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, + { buffer = bufnr, desc = 'Preview git hunk' }); local gs = package.loaded.gitsigns; vim.keymap.set({ 'n', 'v' }, ']c', function() if vim.wo.diff then return ']c'; end - vim.schedule(function () + vim.schedule(function() gs.next_hunk() end); return ''; @@ -60,7 +54,7 @@ return { if vim.wo.diff then return '[c'; end - vim.schedule(function () + vim.schedule(function() gs.next_hunk() end); return ''; @@ -68,6 +62,22 @@ return { end, }, }, + { + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + 'nvim-treesitter/playground', + }, + build = ':TSUpdate', + }, + { 'j-hui/fidget.nvim', }, + { "williamboman/mason.nvim", }, + { "williamboman/mason-lspconfig.nvim", }, + { "neovim/nvim-lspconfig", }, + { 'folke/which-key.nvim', }, + { 'lewis6991/hover.nvim', }, + { 'folke/neodev.nvim', }, + { 'nvim-tree/nvim-web-devicons', }, { 'hrsh7th/nvim-cmp', dependencies = { @@ -78,6 +88,39 @@ return { 'onsails/lspkind.nvim', }, }, + { 'tpope/vim-sleuth', }, + { + 'folke/troube.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons', }, + opts = {}, + lazy = false, + }, + { + 'stevearc/conform.nvim', + opts = { + formatters_by_ft = { + nix = { 'nixpkgs_fmt' }, + }, + format_on_save = { + timeout_ms = 1000, + lsp_fallback = true, + }, + }, + }, + { + 'numToStr/Comment.nvim', + opts = { + extra = { + above = 'gc0', + below = 'gco', + eol = 'gcA', + }, + mappings = { + basic = true, + extra = true, + }, + }, + }, { 'nvim-telescope/telescope.nvim', branch = '0.1.x', @@ -86,10 +129,28 @@ return { { 'nvim-telescope/telescope-fnf-native.nvim', build = 'make', - cond = function () + cond = function() return vim.fn.executable('make') == 1 end }, }, }, + { + 'okuuva/auto-save.nvim', + lazy = false, + event = { 'InsertLeave', 'TextChanged', }, + opts = {}, + }, + { 'tpope/vim-fugitive', }, + { 'tpope/vim-rhubarb', }, + { + 'kdheepak/lazygit.nvim', + dependencies = { 'nvim-lua/plenary.nvim', }, + keys = { { 'gg', ':LazyGit', desc = '[gg] Lazygit', } }, + }, + { 'lambdalisue/suda.vim', }, + { + 'aserowy/tmux.nvim', + config = true, + }, };