diff --git a/.stylua.toml b/.stylua.toml index 3c57f372..9393cf9a 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -2,4 +2,4 @@ column_width = 120 line_endings = "Unix" indent_type = "Spaces" indent_width = 2 -quote_style = "AutoPreferSingle" +quote_style = "AutoPreferDouble" diff --git a/init.lua b/init.lua index 345d7e0c..3100dbfc 100644 --- a/init.lua +++ b/init.lua @@ -43,17 +43,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) --- Configure Neovim tab settings for Go files --- vim.api.nvim_create_autocmd('FileType', { --- pattern = 'go', --- callback = function() --- vim.bo.expandtab = true -- Use spaces instead of tabs --- vim.bo.tabstop = 4 -- Display each tab as 4 spaces --- vim.bo.shiftwidth = 4 -- Indentation size of 4 spaces --- vim.bo.softtabstop = 4 -- key inserts 4 spaces --- end, --- }) - require('rakshit.lazy') -- The line beneath this is called `modeline`. See `:help modeline` diff --git a/lua/rakshit/core/keymaps.lua b/lua/rakshit/core/keymaps.lua index 79c80daf..732ad0a4 100644 --- a/lua/rakshit/core/keymaps.lua +++ b/lua/rakshit/core/keymaps.lua @@ -54,3 +54,10 @@ vim.keymap.set('n', 'tx', 'tabclose', { desc = 'Close current t vim.keymap.set('n', 'tn', 'tabn', { desc = 'Go to next tab' }) -- go to next tab vim.keymap.set('n', 'tp', 'tabp', { desc = 'Go to previous tab' }) -- go to previous tab vim.keymap.set('n', 'tf', 'tabnew %', { desc = 'Open current buffer in new tab' }) -- move current buffer to new tab + +-- Gopher plugin keymaps +vim.keymap.set('n', 'if', ' GoIfErr ', { desc = 'Add if err != nil snippet' }) + +-- Borrowed from my VS Code settings for better Vim navigations +vim.keymap.set('n', 'l', '$', { desc = 'Move to end of the line with leader + l' }) +vim.keymap.set('n', 'h', '_', { desc = 'Move to first character of the line with leader + h' }) diff --git a/lua/rakshit/plugins/debug-mappings.lua b/lua/rakshit/plugins/debug-mappings.lua new file mode 100644 index 00000000..3078cd5c --- /dev/null +++ b/lua/rakshit/plugins/debug-mappings.lua @@ -0,0 +1,36 @@ +return {} +-- dap = { +-- plugin = true, +-- n = { +-- ['db'] = { +-- ' DapToggleBreakpoint ', +-- 'Add breakpoint at line', +-- }, +-- ['dus'] = { +-- function() +-- local widgets = require('dap.ui.widgets') +-- local sidebar = widgets.sidebar(widgets.scopes) +-- sidebar.open() +-- end, +-- 'Open debugging sidebar', +-- }, +-- }, +-- }, +-- dap_go = { +-- plugin = true, +-- n = { +-- ['dgt'] = { +-- function() +-- require('dag-go').debug_test() +-- end, +-- 'Debug go test', +-- }, +-- ['dgl'] = { +-- function() +-- require('dap-go').debug_last() +-- end, +-- 'Debug last go test', +-- }, +-- }, +-- }, +-- } diff --git a/lua/rakshit/plugins/debug.lua b/lua/rakshit/plugins/debug.lua index 52c1bd56..d50c61f8 100644 --- a/lua/rakshit/plugins/debug.lua +++ b/lua/rakshit/plugins/debug.lua @@ -6,100 +6,105 @@ -- be extended to other languages as well. That's why it's called -- kickstart.nvim and not kitchen-sink.nvim ;) -return {} --- -- NOTE: Yes, you can install new plugins here! --- 'mfussenegger/nvim-dap', --- -- NOTE: And you can specify dependencies as well --- dependencies = { --- -- Creates a beautiful debugger UI --- 'rcarriga/nvim-dap-ui', --- --- -- Required dependency for nvim-dap-ui --- 'nvim-neotest/nvim-nio', --- --- -- Installs the debug adapters for you --- 'williamboman/mason.nvim', --- 'jay-babu/mason-nvim-dap.nvim', --- --- -- Add your own debuggers here --- 'leoluz/nvim-dap-go', --- }, --- keys = function(_, keys) --- local dap = require('dap') --- local dapui = require('dapui') --- return { --- -- Basic debugging keymaps, feel free to change to your liking! --- { '', dap.continue, desc = 'Debug: Start/Continue' }, --- { '', dap.step_into, desc = 'Debug: Step Into' }, --- { '', dap.step_over, desc = 'Debug: Step Over' }, --- { '', dap.step_out, desc = 'Debug: Step Out' }, --- { 'b', dap.toggle_breakpoint, desc = 'Debug: Toggle Breakpoint' }, --- { --- 'B', --- function() --- dap.set_breakpoint(vim.fn.input('Breakpoint condition: ')) --- end, --- desc = 'Debug: Set Breakpoint', --- }, --- -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. --- { '', dapui.toggle, desc = 'Debug: See last session result.' }, --- unpack(keys), --- } --- end, --- config = function() --- local dap = require('dap') --- local dapui = require('dapui') --- --- require('mason-nvim-dap').setup({ --- -- Makes a best effort to setup the various debuggers with --- -- reasonable debug configurations --- automatic_installation = true, --- --- -- You can provide additional configuration to the handlers, --- -- see mason-nvim-dap README for more information --- handlers = {}, --- --- -- You'll need to check that you have the required things installed --- -- online, please don't ask me how to install them :) --- ensure_installed = { --- -- Update this to ensure that you have the debuggers for the langs you want --- 'delve', --- }, --- }) --- --- -- Dap UI setup --- -- For more information, see |:help nvim-dap-ui| --- dapui.setup({ --- -- Set icons to characters that are more likely to work in every terminal. --- -- Feel free to remove or use ones that you like more! :) --- -- Don't feel like these are good choices. --- icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, --- controls = { --- icons = { --- pause = '⏸', --- play = '▶', --- step_into = '⏎', --- step_over = '⏭', --- step_out = '⏮', --- step_back = 'b', --- run_last = '▶▶', --- terminate = '⏹', --- disconnect = '⏏', --- }, --- }, --- }) --- --- dap.listeners.after.event_initialized['dapui_config'] = dapui.open --- dap.listeners.before.event_terminated['dapui_config'] = dapui.close --- dap.listeners.before.event_exited['dapui_config'] = dapui.close --- --- -- Install golang specific config --- require('dap-go').setup({ --- delve = { --- -- On Windows delve must be run attached or it crashes. --- -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring --- detached = vim.fn.has('win32') == 0, --- }, --- }) --- end, --- } +return { + -- NOTE: Yes, you can install new plugins here! + 'mfussenegger/nvim-dap', + + -- init = function() + -- require('core.utils').load_mappings('dap') + -- end, + + -- NOTE: And you can specify dependencies as well + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/nvim-dap-ui', + + -- Required dependency for nvim-dap-ui + 'nvim-neotest/nvim-nio', + + -- Installs the debug adapters for you + 'williamboman/mason.nvim', + 'jay-babu/mason-nvim-dap.nvim', + + -- Add your own debuggers here + 'leoluz/nvim-dap-go', + }, + keys = function(_, keys) + local dap = require('dap') + local dapui = require('dapui') + return { + -- Basic debugging keymaps, feel free to change to your liking! + { '', dap.continue, desc = 'Debug: Start/Continue' }, + { '', dap.step_into, desc = 'Debug: Step Into' }, + { '', dap.step_over, desc = 'Debug: Step Over' }, + { '', dap.step_out, desc = 'Debug: Step Out' }, + { 'b', dap.toggle_breakpoint, desc = 'Debug: Toggle Breakpoint' }, + { + 'B', + function() + dap.set_breakpoint(vim.fn.input('Breakpoint condition: ')) + end, + desc = 'Debug: Set Breakpoint', + }, + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + { '', dapui.toggle, desc = 'Debug: See last session result.' }, + unpack(keys), + } + end, + config = function() + local dap = require('dap') + local dapui = require('dapui') + + require('mason-nvim-dap').setup({ + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_installation = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, + }) + + -- Dap UI setup + -- For more information, see |:help nvim-dap-ui| + dapui.setup({ + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + }) + + dap.listeners.after.event_initialized['dapui_config'] = dapui.open + dap.listeners.before.event_terminated['dapui_config'] = dapui.close + dap.listeners.before.event_exited['dapui_config'] = dapui.close + + -- Install golang specific config + require('dap-go').setup({ + delve = { + -- On Windows delve must be run attached or it crashes. + -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring + detached = vim.fn.has('win32') == 0, + }, + }) + end, +} diff --git a/lua/rakshit/plugins/formatting.lua b/lua/rakshit/plugins/formatting.lua index ea0d5841..7615ced1 100644 --- a/lua/rakshit/plugins/formatting.lua +++ b/lua/rakshit/plugins/formatting.lua @@ -14,6 +14,7 @@ return { -- Autoformat }, opts = { notify_on_error = false, + notify_no_formatters = true, format_on_save = { lsp_fallback = true, async = false, @@ -56,14 +57,4 @@ return { -- Autoformat -- javascript = { "prettierd", "prettier", stop_after_first = true }, }, }, - -- Configure Neovim tab settings for Go files - -- vim.api.nvim_create_autocmd('FileType', { - -- pattern = 'go', - -- callback = function() - -- -- vim.bo.expandtab = true -- Use spaces instead of tabs - -- vim.bo.tabstop = 4 -- Display each tab as 4 spaces - -- vim.bo.shiftwidth = 4 -- Indentation size of 4 spaces - -- vim.bo.softtabstop = 4 -- key inserts 4 spaces - -- end, - -- }), } diff --git a/lua/rakshit/plugins/gopher.lua b/lua/rakshit/plugins/gopher.lua new file mode 100644 index 00000000..ed25e693 --- /dev/null +++ b/lua/rakshit/plugins/gopher.lua @@ -0,0 +1,10 @@ +return { + 'olexsmir/gopher.nvim', + ft = 'go', + config = function(_, opts) + require('gopher').setup(opts) + end, + build = function() + vim.cmd([[silent! GoInstallDeps]]) + end, +} diff --git a/lua/rakshit/plugins/lazygit.lua b/lua/rakshit/plugins/lazygit.lua new file mode 100644 index 00000000..0f28e9b7 --- /dev/null +++ b/lua/rakshit/plugins/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/lua/rakshit/plugins/linting.lua b/lua/rakshit/plugins/linting.lua index 2d5e030a..9482d610 100644 --- a/lua/rakshit/plugins/linting.lua +++ b/lua/rakshit/plugins/linting.lua @@ -56,9 +56,9 @@ return { end, }) - vim.keymap.set('n', 'l', function() - lint.try_lint() - end, { desc = 'Trigger linting for current file' }) + -- vim.keymap.set('n', 'l', function() + -- lint.try_lint() + -- end, { desc = 'Trigger linting for current file' }) end, }, } diff --git a/lua/rakshit/plugins/lsp/lspconfig.lua b/lua/rakshit/plugins/lsp/lspconfig.lua index bb578dde..0a7bd2b8 100644 --- a/lua/rakshit/plugins/lsp/lspconfig.lua +++ b/lua/rakshit/plugins/lsp/lspconfig.lua @@ -50,6 +50,21 @@ return { -- function will be executed to configure the current buffer -- import lspconfig plugin local lspconfig = require('lspconfig') + local util = require('lspconfig/util') + lspconfig.gopls.setup({ + cmd = { 'gopls' }, + filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, + root_dir = util.root_pattern('go.work', 'go.mod', '.git'), + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + }, + }, + }) -- import mason_lspconfig plugin local mason_lspconfig = require('mason-lspconfig') diff --git a/lua/rakshit/plugins/nvim-dap-go.lua b/lua/rakshit/plugins/nvim-dap-go.lua new file mode 100644 index 00000000..b74d2112 --- /dev/null +++ b/lua/rakshit/plugins/nvim-dap-go.lua @@ -0,0 +1,9 @@ +return { + 'leoluz/nvim-dap-go', + ft = 'go', + dependencies = 'mfussenegger/nvim-dap', + config = function(_, opts) + require('dap-go').setup(opts) + -- require('core-utils').load_mappings('dap_go') + end, +} diff --git a/lua/rakshit/plugins/which-key.lua b/lua/rakshit/plugins/which-key.lua index 52af66fb..e19d3aeb 100644 --- a/lua/rakshit/plugins/which-key.lua +++ b/lua/rakshit/plugins/which-key.lua @@ -63,7 +63,7 @@ return { -- Useful plugin to show you pending keybinds. { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + -- { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, }, }