diff --git a/lazy-lock.json b/lazy-lock.json index 9424d2b..9c0a278 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,17 +1,32 @@ { + "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "gruvbox.nvim": { "branch": "main", "commit": "561126520034a1dac2f78ab063db025d12555998" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "a324581a3c83fdacdb9804b79de1cbe00ce18550" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "mini.animate": { "branch": "main", "commit": "8814b56e282cd86635ce9a392ed56b6a85f59731" }, + "mini.starter": { "branch": "main", "commit": "cdf909e5bda577e09c61fa6d9a36bb2a88dbc636" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "9d6826582a3e8c84787bd7355df22a2812a1ad59" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-dap": { "branch": "master", "commit": "b516f20b487b0ac6a281e376dfac1d16b5040041" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "b9c795d3973e8eec22706af14959bc60c579e771" }, "nvim-lspconfig": { "branch": "master", "commit": "ead0f5f342d8d323441e7d4b88f0fc436a81ad5f" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-treesitter": { "branch": "main", "commit": "cb2cb74f3c3cbbcc17e79cada2060165d616d849" }, "nvim-web-devicons": { "branch": "master", "commit": "737cf6c657898d0c697311d79d361288a1343d50" }, "nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" } + "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, + "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua new file mode 100644 index 0000000..cda314d --- /dev/null +++ b/lua/plugins/completions.lua @@ -0,0 +1,45 @@ +return { + { + "hrsh7th/cmp-nvim-lsp" + }, + { + "L3MON4D3/LuaSnip", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + }, + { + "hrsh7th/nvim-cmp", + version = false, + config = function() + local cmp = require("cmp") + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, -- For luasnip users. + }, { + { name = "buffer" }, + }), + }) + end, + }, +} diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..b3ccf3d --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,69 @@ +return { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio", + "jay-babu/mason-nvim-dap.nvim" + }, + config = function() + local dap, dapui = require("dap"), require("dapui") + dapui.setup(); + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + dapui.close() + end + + -- C/C++/Rust (via gdb) + dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" } + } + + local c_conf = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + { + name = "Select and attach to process", + type = "gdb", + request = "attach", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + pid = function() + local name = vim.fn.input('Executable name (filter): ') + return require("dap.utils").pick_process({ filter = name }) + end, + cwd = '${workspaceFolder}' + }, + { + name = 'Attach to gdbserver :1234', + type = 'gdb', + request = 'attach', + target = 'localhost:1234', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}' + }, + } + dap.configurations.c = c_conf + dap.configurations.cpp = c_conf + end +} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..969db07 --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,23 @@ +return { + "kdheepak/lazygit.nvim", + --cmd = { + -- "LazyGit", + -- "LazyGitConfig", + -- "LazyGitCurrentFile", + -- "LazyGitFilter", + -- "LazyGitFilterCurrentFile", + --}, + dependencies = { + "nvim-lua/plenary.nvim", + "folke/which-key.nvim", + }, + config = function() + require('which-key').add({ + { "g", group = "git" }, + { "gb", "Telescope git_branches", desc = "Branches" }, + { "gg", "Telescope git_commits", desc = "LazyGit" }, + { "gl", "LazyGit", desc = "Commits" }, + { "gs", "Telescope git_status", desc = "Status" }, + }) + end +} diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua index 98a1150..b53b252 100644 --- a/lua/plugins/lsp-config.lua +++ b/lua/plugins/lsp-config.lua @@ -5,6 +5,7 @@ return { { "mason-org/mason.nvim", opts = {} }, { "neovim/nvim-lspconfig", + dependencies = "folke/which-key.nvim", config = function() vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('UserLspConfig', {}), @@ -15,28 +16,27 @@ return { -- Buffer local mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions local opts = { buffer = ev.buf } - vim.keymap.set('n', 'le', vim.diagnostic.open_float) - vim.keymap.set('n', 'ln', vim.diagnostic.goto_next) - vim.keymap.set('n', 'lN', vim.diagnostic.goto_prev) - vim.keymap.set('n', 'lj', vim.diagnostic.setloclist) + require('which-key').add({ + { "l", group = "lsp" }, - vim.keymap.set('n', 'lD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'ld', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'lk', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'li', vim.lsp.buf.implementation, opts) - --vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - --vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) - --vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) - --vim.keymap.set('n', 'wl', function() - -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - --end, opts) - vim.keymap.set('n', 'lt', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'lR', vim.lsp.buf.rename, opts) - vim.keymap.set({ 'n', 'v' }, 'la', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'lr', vim.lsp.buf.references, opts) - vim.keymap.set('n', 'lf', function() - vim.lsp.buf.format { async = true } - end, opts) + { 'le', vim.diagnostic.open_float, desc = "Explanation" }, + { 'ln', vim.diagnostic.goto_next, desc = "Next Issue" }, + { 'lN', vim.diagnostic.goto_prev, desc = "Previous Issue" }, + { 'lj', vim.diagnostic.setloclist, desc = "Diagnostic list" }, + + { 'lD', vim.lsp.buf.declaration, opts, desc = "Declaration" }, + { 'ld', vim.lsp.buf.definition, opts, desc = "Definition" }, + { 'lk', vim.lsp.buf.hover, opts, desc = "Hover" }, + { 'li', vim.lsp.buf.implementation, opts, desc = "Implmentation" }, + { 'lt', vim.lsp.buf.type_definition, opts, desc = "Type" }, + { 'lR', vim.lsp.buf.rename, opts, desc = "Rename" }, + { 'la', vim.lsp.buf.code_action, opts, desc = "Actions" }, + { 'lr', vim.lsp.buf.references, opts, desc = "References" }, + + { 'lf', function() + vim.lsp.buf.format { async = true } + end, opts } + }) end, }) end diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index 6c3f8be..6eba18f 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -13,10 +13,11 @@ return { dependencies = { "nvim-lua/plenary.nvim", "nvim-neo-tree/neo-tree.nvim", -- makes sure that this loads after Neo-tree. + "folke/which-key.nvim" }, config = function() require("lsp-file-operations").setup() - vim.keymap.set("n", "s", ':Neotree toggle') + require('which-key').add({ { "s", ':Neotree toggle' } }) end, }, { diff --git a/lua/plugins/small-tweaks.lua b/lua/plugins/small-tweaks.lua new file mode 100644 index 0000000..94b1114 --- /dev/null +++ b/lua/plugins/small-tweaks.lua @@ -0,0 +1,47 @@ +return { + { "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} }, + { + 'echasnovski/mini.animate', + version = false, + config = function() + local animate = require('mini.animate') + animate.setup({ + scroll = { timing = animate.gen_timing.linear({ duration = 50, unit = 'total' }) }, + cursor = { enable = false } + }) + end + }, + { + 'echasnovski/mini.starter', + version = false, + config = function() + require('mini.starter').setup() + end + }, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + opts = {} -- this is equalent to setup({}) function + }, + { + 'akinsho/toggleterm.nvim', + config = function() + require("toggleterm").setup({ + hide_numbers = true, + start_in_insert = true, + shell = vim.o.shell, + }) + -- Get out of terminal! + function _G.set_terminal_keymaps() + local opts = { buffer = 0 } + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', '', [[]], opts) + end + + vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + + -- Open terminal keymap + vim.keymap.set('n', 't', ":ToggleTerm", { noremap = true, silent = true }) + end + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index b28f494..b0b2fa3 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,15 +1,22 @@ return { { 'nvim-telescope/telescope.nvim', - dependencies = { "nvim-lua/plenary.nvim" }, + dependencies = { "nvim-lua/plenary.nvim", "folke/which-key.nvim" }, opts = {}, - config = function() + config = function() local builtin = require('telescope.builtin') - vim.keymap.set('n', 'ff', builtin.find_files, {}) - vim.keymap.set('n', 'fo', builtin.oldfiles, {}) - vim.keymap.set('n', 'fg', builtin.live_grep, {}) - vim.keymap.set('n', 'fh', builtin.help_tags, {}) - end + require('which-key').add({ + { "ff", builtin.find_files, desc = "Find" }, + { "fg", builtin.live_grep, desc = "Grep" }, + { "fh", builtin.help_tags, desc = "Help Tags" }, + { "fo", builtin.help_tags, desc = "Old Files" }, + + }) + --vim.keymap.set('n', 'ff', builtin.find_files, {}) + --vim.keymap.set('n', 'fo', builtin.oldfiles, {}) + --vim.keymap.set('n', 'fg', builtin.live_grep, {}) + --vim.keymap.set('n', 'fh', builtin.help_tags, {}) + end, }, { 'nvim-telescope/telescope-ui-select.nvim', @@ -26,4 +33,3 @@ return { end } } - diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 7f25a26..d6e26c6 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -2,7 +2,7 @@ return { 'nvim-treesitter/nvim-treesitter', lazy = false, build = ':TSUpdate', - config = function() + config = function() -- Auto launch for every TSInstalled filetype vim.api.nvim_create_autocmd('FileType', { pattern = require('nvim-treesitter').get_installed(), diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..aeb5f54 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,41 @@ +return { + "folke/which-key.nvim", + lazy = false, + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 0 + + local wk = require('which-key') + wk.setup({ + hide_statusline = false, + default_keymap_settings = { + silent = true, + noremap = true, + }, + default_mode = 'n', + }) + + -- Map window keys to leader w + vim.cmd [[nmap w ]] + wk.add({ + { "w", group = "window" }, + { "w+", desc = "Increase height" }, + { "w-", desc = "Decrease height" }, + { "w<", desc = "Decrease width" }, + { "w=", desc = "Equally high and wide" }, + { "w>", desc = "Increase width" }, + { "wT", desc = "Break out into a new tab" }, + { "wh", desc = "Go to the left window" }, + { "wj", desc = "Go to the down window" }, + { "wk", desc = "Go to the up window" }, + { "wl", desc = "Go to the right window" }, + { "wq", desc = "Quit a window" }, + { "ws", desc = "Split window" }, + { "wv", desc = "Split window vertically" }, + { "ww", desc = "Pick Window" }, + { "wx", desc = "Swap current with next" }, + { "w|", desc = "Max out the width" }, + + }) + end +}