diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 898dd4e..52be4e5 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -86,6 +86,13 @@ with final.pkgs.lib; let tokyonight-nvim # QOL Plugin for visuals mostly mini-nvim # https://github.com/echasnovski/mini.nvim/ + # Debugging + nvim-dap + + # Copilot related plugins + CopilotChat-nvim + copilot-cmp + copilot-lua ]; extraPackages = with pkgs; [ @@ -99,6 +106,9 @@ with final.pkgs.lib; let alejandra # amazing nix autoformatter stylua # lua formatter google-java-format # java formatter based off google guidelines + + # misc + nodejs # eww ]; in { # This is the neovim derivation diff --git a/nvim/init.lua b/nvim/init.lua index 560c45c..92159e7 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -44,6 +44,14 @@ opt.cmdheight = 0 opt.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] +-- Restore cursor position +vim.api.nvim_create_autocmd({ 'BufReadPost' }, { + pattern = { '*' }, + callback = function() + vim.api.nvim_exec2('silent! normal! g`"zv', { output = false }) + end, +}) + -- Configure Neovim diagnostic messages local function prefix_diagnostic(prefix, diagnostic) @@ -102,4 +110,4 @@ cmd.packadd('cfilter') -- Allows filtering the quickfix list with :cfdo vim.g.sqlite_clib_path = require('luv').os_getenv('LIBSQLITE') -- Vim Theme -vim.cmd.colorscheme 'tokyonight-night' +vim.cmd.colorscheme('tokyonight-night') diff --git a/nvim/plugin/completion.lua b/nvim/plugin/completion.lua index 086b589..79792e7 100644 --- a/nvim/plugin/completion.lua +++ b/nvim/plugin/completion.lua @@ -105,6 +105,7 @@ cmp.setup { -- The insertion order influences the priority of the sources { name = 'nvim_lsp', keyword_length = 3 }, { name = 'nvim_lsp_signature_help', keyword_length = 3 }, + { name = 'copilot' }, { name = 'buffer' }, { name = 'path' }, }, diff --git a/nvim/plugin/copilot.lua b/nvim/plugin/copilot.lua new file mode 100644 index 0000000..e51701b --- /dev/null +++ b/nvim/plugin/copilot.lua @@ -0,0 +1,15 @@ +-- Copilot related plugins setup +require('CopilotChat').setup { + debug = true, +} + +require('copilot_cmp').setup() + +require('copilot').setup { + suggestion = { enabled = false }, + panel = { enabled = false }, + filetypes = { + ['*'] = false, + }, + copilot_node_command = 'node', +} diff --git a/nvim/plugin/dap.lua b/nvim/plugin/dap.lua new file mode 100644 index 0000000..ad838ce --- /dev/null +++ b/nvim/plugin/dap.lua @@ -0,0 +1,30 @@ +local dap = require('dap') +dap.adapters.gdb = { + type = 'executable', + command = 'gdb', + args = { '-i', 'dap' }, +} + +dap.configurations.c = { + { + name = 'Launch', + type = 'gdb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + stopAtBeginningOfMainSubprogram = false, + }, +} + +dap.configurations.cpp = { + { + name = 'Launch', + type = 'gdb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + stopAtBeginningOfMainSubprogram = false, + }, +} diff --git a/nvim/plugin/keymaps.lua b/nvim/plugin/keymaps.lua index 3d5a931..ae30f90 100644 --- a/nvim/plugin/keymaps.lua +++ b/nvim/plugin/keymaps.lua @@ -174,18 +174,47 @@ keymap.set('n', ']h', function() } end, { noremap = true, silent = true, desc = 'next [h]int diagnostic' }) -local function toggle_spell_check() - ---@diagnostic disable-next-line: param-type-mismatch - vim.opt.spell = not (vim.opt.spell:get()) -end - -keymap.set('n', 'S', toggle_spell_check, { noremap = true, silent = true, desc = 'toggle [S]pell' }) - keymap.set('n', '', 'zz', { desc = 'move [d]own half-page and center' }) keymap.set('n', '', 'zz', { desc = 'move [u]p half-page and center' }) keymap.set('n', '', 'zz', { desc = 'move DOWN [f]ull-page and center' }) keymap.set('n', '', 'zz', { desc = 'move UP full-page and center' }) +-- DAP Keymaps +vim.api.nvim_set_keymap( + 'n', + 'db', + ':lua require"dap".toggle_breakpoint()', + { noremap = true, silent = true, desc = 'debugger set [b]reakpoint' } +) + +vim.api.nvim_set_keymap( + 'n', + 'dc', + ':lua require"dap".continue()', + { noremap = true, silent = true, desc = 'debugger [c]ontinue' } +) + +vim.api.nvim_set_keymap( + 'n', + 'dn', + ':lua require"dap".step_over()', + { noremap = true, silent = true, desc = 'debugger [s]tep over' } +) + +vim.api.nvim_set_keymap( + 'n', + 'di', + ':lua require"dap".step_into()', + { noremap = true, silent = true, desc = 'debugger [s]tep into' } +) + +vim.api.nvim_set_keymap( + 'n', + 'dr', + ':lua require"dap".repl.open()', + { noremap = true, silent = true, desc = 'debugger [r]epl' } +) + --- Disabled keymaps [enable at your own risk] -- Automatic management of search highlight diff --git a/nvim/plugin/telescope.lua b/nvim/plugin/telescope.lua index ad3bddb..60426a7 100644 --- a/nvim/plugin/telescope.lua +++ b/nvim/plugin/telescope.lua @@ -21,54 +21,6 @@ local layout_config = { }, } --- Fall back to find_files if not in a git repo -local project_files = function() - local opts = {} -- define here if you want to define something - local ok = pcall(builtin.git_files, opts) - if not ok then - builtin.find_files(opts) - end -end - ----@param picker function the telescope picker to use -local function grep_current_file_type(picker) - local current_file_ext = vim.fn.expand('%:e') - local additional_vimgrep_arguments = {} - if current_file_ext ~= '' then - additional_vimgrep_arguments = { - '--type', - current_file_ext, - } - end - local conf = require('telescope.config').values - picker { - vimgrep_arguments = vim.tbl_flatten { - conf.vimgrep_arguments, - additional_vimgrep_arguments, - }, - } -end - ---- Grep the string under the cursor, filtering for the current file type -local function grep_string_current_file_type() - grep_current_file_type(builtin.grep_string) -end - ---- Live grep, filtering for the current file type -local function live_grep_current_file_type() - grep_current_file_type(builtin.live_grep) -end - ---- Like live_grep, but fuzzy (and slower) -local function fuzzy_grep(opts) - opts = vim.tbl_extend('error', opts or {}, { search = '', prompt_title = 'Fuzzy grep' }) - builtin.grep_string(opts) -end - -local function fuzzy_grep_current_file_type() - grep_current_file_type(fuzzy_grep) -end - vim.keymap.set('n', 'tp', function() builtin.find_files() end, { desc = '[t]elescope find files - ctrl[p] style' }) @@ -83,7 +35,6 @@ vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' } vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - telescope.setup { defaults = { path_display = { diff --git a/nvim/plugin/which-key.lua b/nvim/plugin/which-key.lua index def52f8..dc6b98f 100644 --- a/nvim/plugin/which-key.lua +++ b/nvim/plugin/which-key.lua @@ -1,3 +1,13 @@ -require('which-key').setup { - preset = 'helix' +local whichkey = require('which-key') + +whichkey.setup() + +whichkey.add { + { 'c', group = '[C]ode' }, + { 'd', group = '[D]ocument' }, + { 'r', group = '[R]ename' }, + { 's', group = '[S]earch' }, + { 'w', group = '[W]orkspace' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }