diff --git a/init.lua b/init.lua index 4ce35f4b..c8dbc36b 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -243,18 +243,18 @@ require('lazy').setup({ -- require('gitsigns').setup({ ... }) -- -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, + -- { -- Adds git related signs to the gutter, as well as utilities for managing changes + -- 'lewis6991/gitsigns.nvim', + -- opts = { + -- signs = { + -- add = { text = '+' }, + -- change = { text = '~' }, + -- delete = { text = '_' }, + -- topdelete = { text = '‾' }, + -- changedelete = { text = '~' }, + -- }, + -- }, + -- }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- @@ -615,7 +615,40 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, + gopls = { + -- gofumpt = true, + -- codelenses = { + -- gc_details = false, + -- generate = true, + -- regenerate_cgo = true, + -- run_govulncheck = true, + -- test = true, + -- tidy = true, + -- upgrade_dependency = true, + -- vendor = true, + -- }, + -- hints = { + -- assignVariableTypes = true, + -- compositeLiteralFields = true, + -- compositeLiteralTypes = true, + -- constantValues = true, + -- functionTypeParameters = true, + -- parameterNames = true, + -- rangeVariableTypes = true, + -- }, + -- analyses = { + -- fieldalignment = true, + -- nilness = true, + -- unusedparams = true, + -- unusedwrite = true, + -- useany = true, + -- }, + -- usePlaceholders = true, + -- completeUnimported = true, + -- staticcheck = true, + -- directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' }, + -- semanticTokens = true, + }, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -656,6 +689,12 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'prettierd', + 'goimports', + 'gofumpt', + 'gomodifytags', + 'impl', + 'delve', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -708,6 +747,8 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + yaml = { 'prettierd' }, + go = { 'goimports', 'gofumpt' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -737,12 +778,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -825,6 +866,7 @@ require('lazy').setup({ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it group_index = 0, }, + { name = 'copilot' }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, @@ -838,13 +880,14 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + 'catppuccin/nvim', + name = 'catppuccin', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'catppuccin-mocha' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' @@ -897,7 +940,24 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'go', + 'gomod', + 'gowork', + 'gosum', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'yaml', + 'vim', + 'vimdoc', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -926,12 +986,12 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. diff --git a/lua/custom/plugins/alpha.lua b/lua/custom/plugins/alpha.lua new file mode 100644 index 00000000..f3bea35b --- /dev/null +++ b/lua/custom/plugins/alpha.lua @@ -0,0 +1,31 @@ +return { + { + 'goolord/alpha-nvim', + event = 'VimEnter', + enabled = true, + init = false, + dependencies = { + 'echasnovski/mini.icons', + 'nvim-lua/plenary.nvim', + }, + config = function() + local alpha = require 'alpha' + local dashboard = require 'alpha.themes.dashboard' + + dashboard.section.buttons.val = { + dashboard.button('e', ' New file', 'ene '), + dashboard.button('f', '󰈞 Find file', 'Telescope find_files'), + dashboard.button('h', '󰊄 Recently opened files', 'Telescope oldfiles'), + -- dashboard.button('SPC f r', ' Frecency/MRU'), + dashboard.button('g', '󰈬 Find word', 'Telescope live_grep'), + -- dashboard.button(' fm', ' Jump to bookmarks'), + dashboard.button('s', ' Open last session', ' lua require("persistence").load() '), + dashboard.button('sl', ' Select Session', ' lua require("persistence").select() '), + dashboard.button('u', ' Update plugins', 'Lazy sync'), + dashboard.button('c', ' Configuration', "lua require('telescope.builtin').find_files { cwd = vim.fn.stdpath 'config' } "), + dashboard.button('q', '󰅚 Quit', 'qa'), + } + alpha.setup(dashboard.config) + end, + }, +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..845f133f --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,52 @@ +local on_attach = function(on_attach, name) + return vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local buffer = args.buf ---@type number + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and (not name or client.name == name) then + return on_attach(client, buffer) + end + end, + }) +end + +return { + { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + -- new + -- event = 'InsertEnter', + build = ':Copilot auth', + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + filetypes = { + markdown = true, + help = true, + }, + }, + }, + { + 'zbirenbaum/copilot-cmp', + dependencies = 'copilot.lua', + opts = {}, + config = function(_, opts) + local copilot_cmp = require 'copilot_cmp' + copilot_cmp.setup(opts) + on_attach(function(client) + copilot_cmp._on_insert_enter {} + end, 'copilot') + end, + }, + { + 'olimorris/codecompanion.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + 'hrsh7th/nvim-cmp', -- Optional: For using slash commands and variables in the chat buffer + 'nvim-telescope/telescope.nvim', -- Optional: For using slash commands + { 'stevearc/dressing.nvim', opts = {} }, -- Optional: Improves `vim.ui.select` + }, + config = true, + }, +} diff --git a/lua/custom/plugins/copilot_chat.lua b/lua/custom/plugins/copilot_chat.lua new file mode 100644 index 00000000..da009981 --- /dev/null +++ b/lua/custom/plugins/copilot_chat.lua @@ -0,0 +1,51 @@ +return { + { + 'CopilotC-Nvim/CopilotChat.nvim', + branch = 'canary', + dependencies = { + { 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim + { 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper + }, + build = 'make tiktoken', -- Only on MacOS or Linux + opts = { + debug = true, -- Enable debugging + context = 'buffer', + }, + keys = { + { + 'aa', + function() + local chat = require 'CopilotChat' + chat.toggle() + end, + desc = 'Copilot toggle chat', + }, + { + 'aq', + function() + local input = vim.fn.input 'Quick Chat: ' + if input ~= '' then + require('CopilotChat').ask(input, { selection = require('CopilotChat.select').buffer }) + end + end, + desc = 'Copilot quick chat', + }, + { + 'ax', + function() + local chat = require 'CopilotChat' + chat.reset() + end, + desc = 'Copilot chat reset', + }, + { + 'ap', + function() + local actions = require 'CopilotChat.actions' + require('CopilotChat.integrations.telescope').pick(actions.prompt_actions()) + end, + desc = 'Copilot chat prompt actions', + }, + }, + }, +} diff --git a/lua/custom/plugins/go.lua b/lua/custom/plugins/go.lua new file mode 100644 index 00000000..8fd67602 --- /dev/null +++ b/lua/custom/plugins/go.lua @@ -0,0 +1,64 @@ +local on_attach = function(client, bufnr) + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end +end + +require('lspconfig').gopls.setup { + on_attach = on_attach, +} + +return { + { + 'leoluz/nvim-dap-go', + opts = {}, + }, + { + 'fredrikaverpil/neotest-golang', + }, + { + 'echasnovski/mini.icons', + opts = { + file = { + ['.go-version'] = { glyph = '', hl = 'MiniIconsBlue' }, + }, + filetype = { + gotmpl = { glyph = '󰟓', hl = 'MiniIconsGrey' }, + }, + }, + }, + { + 'mfussenegger/nvim-dap', + optional = true, + dependencies = { + { + 'leoluz/nvim-dap-go', + opts = {}, + }, + }, + }, + { + 'nvim-neotest/neotest', + optional = true, + dependencies = { + 'fredrikaverpil/neotest-golang', + }, + opts = { + adapters = { + ['neotest-golang'] = { + -- Here we can set options for neotest-golang, e.g. + -- go_test_args = { "-v", "-race", "-count=1", "-timeout=60s" }, + dap_go_enabled = true, -- requires leoluz/nvim-dap-go + }, + }, + }, + }, +} diff --git a/lua/custom/plugins/grug.lua b/lua/custom/plugins/grug.lua new file mode 100644 index 00000000..294bec51 --- /dev/null +++ b/lua/custom/plugins/grug.lua @@ -0,0 +1,22 @@ +return { + 'MagicDuck/grug-far.nvim', + opts = { headerMaxWidth = 80 }, + cmd = 'GrugFar', + keys = { + { + 'sR', + function() + local grug = require 'grug-far' + local ext = vim.bo.buftype == '' and vim.fn.expand '%:e' + grug.open { + transient = true, + prefills = { + filesFilter = ext and ext ~= '' and '*.' .. ext or nil, + }, + } + end, + mode = { 'n', 'v' }, + desc = 'Search and Replace', + }, + }, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..d40d980f 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,11 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information +vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' }, { command = 'checktime' }) + +vim.keymap.set('n', '', '5<', { desc = 'Decrease window width' }) +vim.keymap.set('n', '', '5>', { desc = 'Increase window width' }) +vim.keymap.set('n', '', '1+', { desc = 'Increase window height' }) +vim.keymap.set('n', '', '1-', { desc = 'Decrease window height' }) + return {} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000..2b301957 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,21 @@ +return { + 'kdheepak/lazygit.nvim', + lazy = true, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + dependencies = { + 'nvim-lua/plenary.nvim', + }, + keys = { + { 'gg', 'LazyGit', desc = 'Lazygit (Root Dir)' }, + { 'gf', 'LazyGitFilterCurrentFile', desc = 'Lazygit Current File History' }, + { 'gl', 'LazyGitFilter', desc = 'Lazygit log' }, + { 'gb', 'Gitsigns blame', desc = 'Git blame' }, + { 'gs', 'Telescope git_status', desc = 'Git Status' }, + }, +} diff --git a/lua/custom/plugins/marks.lua b/lua/custom/plugins/marks.lua new file mode 100644 index 00000000..2c63d712 --- /dev/null +++ b/lua/custom/plugins/marks.lua @@ -0,0 +1,5 @@ +return { + 'chentoast/marks.nvim', + event = 'VeryLazy', + opts = {}, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 00000000..6092ff5a --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,22 @@ +return { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + dependencies = { + { 'echasnovski/mini.icons', opts = {} }, + { 'nvim-tree/nvim-web-devicons', opts = {} }, + }, + config = function() + require('oil').setup { + keymaps = { + [''] = 'actions.close', + [''] = false, + }, + } + end, + keys = { + -- { '=', 'Oil', mode = 'n', desc = 'Open Filesystem' }, + { '-', 'Oil --float', mode = 'n', desc = 'Open Floating Filesystem' }, + }, +} diff --git a/lua/custom/plugins/session.lua b/lua/custom/plugins/session.lua new file mode 100644 index 00000000..4846774e --- /dev/null +++ b/lua/custom/plugins/session.lua @@ -0,0 +1,7 @@ +return { + { + 'folke/persistence.nvim', + event = 'BufReadPre', + opts = {}, + }, +} diff --git a/lua/custom/plugins/tmux_navigator.lua b/lua/custom/plugins/tmux_navigator.lua new file mode 100644 index 00000000..58852263 --- /dev/null +++ b/lua/custom/plugins/tmux_navigator.lua @@ -0,0 +1,17 @@ +return { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + }, + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, + }, +} diff --git a/lua/custom/plugins/vim_test.lua b/lua/custom/plugins/vim_test.lua new file mode 100644 index 00000000..06e11a3d --- /dev/null +++ b/lua/custom/plugins/vim_test.lua @@ -0,0 +1,14 @@ +return { + 'vim-test/vim-test', + dependencies = { + 'preservim/vimux', + }, + setup = { + vim.cmd 'let test#strategy = "vimux"', + }, + keys = { + { 'tt', 'TestFile', { desc = 'Test file' } }, + { 'tn', 'TestNearest', { desc = 'Test nearest' } }, + { 'tl', 'TestLast', { desc = 'Test last' } }, + }, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 2226d963..958818c2 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -90,16 +90,16 @@ return { } -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } - -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) - -- end + vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) + vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) + local breakpoint_icons = vim.g.have_nerd_font + and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } + or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } + for type, icon in pairs(breakpoint_icons) do + local tp = 'Dap' .. type + local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' + vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + end dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_terminated['dapui_config'] = dapui.close diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index 4bcc70f4..50840d43 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -6,6 +6,7 @@ return { { 'lewis6991/gitsigns.nvim', opts = { + current_line_blame = true, on_attach = function(bufnr) local gitsigns = require 'gitsigns'