From 373c8dc5d31ce2f15adf0e890941bfea869490ac Mon Sep 17 00:00:00 2001 From: ngorana Date: Fri, 9 Aug 2024 11:10:39 +0100 Subject: [PATCH] personal configuations merge conflicts adjusted --- init.lua | 163 +++++++++-------------------- lua/custom/plugins/harpoon.lua | 40 +++++++ lua/custom/plugins/neogit.lua | 12 +++ lua/custom/plugins/oil.lua | 24 +++++ lua/custom/plugins/undotree.lua | 6 ++ lua/custom/plugins/vim-test.lua | 11 ++ lua/custom/plugins/vim-tmux.lua | 18 ++++ lua/custom/plugins/vim_cmake.lua | 3 + lua/kickstart/plugins/debug.lua | 148 +++++++++++++++++++++++++- lua/kickstart/plugins/gitsigns.lua | 1 + lua/kickstart/plugins/neo-tree.lua | 25 ----- vim-test.lua | 11 ++ 12 files changed, 318 insertions(+), 144 deletions(-) create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/neogit.lua create mode 100644 lua/custom/plugins/oil.lua create mode 100644 lua/custom/plugins/undotree.lua create mode 100644 lua/custom/plugins/vim-test.lua create mode 100644 lua/custom/plugins/vim-tmux.lua create mode 100644 lua/custom/plugins/vim_cmake.lua delete mode 100644 lua/kickstart/plugins/neo-tree.lua create mode 100644 vim-test.lua diff --git a/init.lua b/init.lua index 220d3045..fb52b008 100644 --- a/init.lua +++ b/init.lua @@ -1,98 +1,12 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) 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 +vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir' + +vim.opt.wrap = false -- [[ Setting options ]] -- See `:help vim.opt` -- NOTE: You can change these options as you wish! @@ -102,7 +16,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' @@ -156,7 +70,11 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +vim.opt.termguicolors = true +vim.opt.tabstop = 4 + +-- -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -167,6 +85,8 @@ vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- Netrw keymaps + -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. @@ -176,10 +96,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -369,7 +289,7 @@ require('lazy').setup({ vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'ss', builtin.find_files, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) @@ -569,17 +489,27 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, -- pyright = {}, - -- rust_analyzer = {}, + rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, + tsserver = {}, + cssls = { + settings = { + css = { + validate = true, + lint = { + unknownAtRules = 'ignore', + }, + }, + }, + }, -- lua_ls = { @@ -661,7 +591,8 @@ require('lazy').setup({ -- python = { "isort", "black" }, -- -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + javascript = { "prettierd", "prettier", stop_after_first = true }, + cpp = { { 'clang-format' } }, }, }, }, @@ -686,12 +617,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', @@ -787,13 +718,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', priority = 1000, -- Make sure to load this before all the other start plugins. + name = 'catppuccin', 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' @@ -852,7 +784,7 @@ require('lazy').setup({ -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. -- If you are experiencing weird indenting issues, add the language to -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, + additional_vim_regex_highlighting = { 'ruby', 'javascript', 'typescript' }, }, indent = { enable = true, disable = { 'ruby' } }, }, @@ -880,19 +812,18 @@ 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.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + 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. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..18796fa9 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,40 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + vim.keymap.set('n', 'a', function() + harpoon:list():add() + end, { desc = 'Add Buffer to Harpoon' }) + vim.keymap.set('n', '', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + vim.keymap.set('n', '1', function() + harpoon:list():select(1) + end, { desc = 'First Buffer in Harpoon' }) + vim.keymap.set('n', '2', function() + harpoon:list():select(2) + end, { desc = 'Second Buffer in Harpoon' }) + vim.keymap.set('n', '3', function() + harpoon:list():select(3) + end, { desc = 'Third Buffer in Harpoon' }) + vim.keymap.set('n', '4', function() + harpoon:list():select(4) + end, { desc = 'Fourth Buffer in Harpoon' }) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', '', function() + harpoon:list():prev() + end) + vim.keymap.set('n', '', function() + harpoon:list():next() + end) + end, +} diff --git a/lua/custom/plugins/neogit.lua b/lua/custom/plugins/neogit.lua new file mode 100644 index 00000000..357f3036 --- /dev/null +++ b/lua/custom/plugins/neogit.lua @@ -0,0 +1,12 @@ +return { + 'NeogitOrg/neogit', + dependencies = { + 'nvim-lua/plenary.nvim', -- required + 'sindrets/diffview.nvim', -- optional - Diff integration + + -- Only one of these is needed, not both. + 'nvim-telescope/telescope.nvim', -- optional + 'ibhagwan/fzf-lua', -- optional + }, + config = true, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 00000000..e92a900d --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,24 @@ +return { + { + 'stevearc/oil.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('oil').setup { + columns = { 'icon' }, + keymaps = { + [''] = false, + [''] = 'actions.select_vsplit', + }, + view_options = { + show_hidden = true, + }, + } + + -- Open parent directory in current window + vim.keymap.set('n', 'n', 'Oil', { desc = 'Open parent directory' }) + + -- Open parent directory in floating window + vim.keymap.set('n', '-', require('oil').toggle_float) + end, + }, +} diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua new file mode 100644 index 00000000..122a32b6 --- /dev/null +++ b/lua/custom/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + 'mbbill/undotree', + config = function() + vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) + end, +} diff --git a/lua/custom/plugins/vim-test.lua b/lua/custom/plugins/vim-test.lua new file mode 100644 index 00000000..3ace7bf0 --- /dev/null +++ b/lua/custom/plugins/vim-test.lua @@ -0,0 +1,11 @@ +return { + 'vim-test/vim-test', + dependencies = { + 'preservim/vimux', + }, + vim.keymap.set('n', 't', ':TestNearest'), + vim.keymap.set('n', 'T', ':TestFile'), + vim.keymap.set('n', 'm', ':TestSuite'), + vim.keymap.set('n', 'l', ':TestLast'), + vim.keymap.set('n', 'g', ':TestVisit'), +} diff --git a/lua/custom/plugins/vim-tmux.lua b/lua/custom/plugins/vim-tmux.lua new file mode 100644 index 00000000..9d680e26 --- /dev/null +++ b/lua/custom/plugins/vim-tmux.lua @@ -0,0 +1,18 @@ +return { + 'christoomey/vim-tmux-navigator', + lazy = false, + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + }, + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, + }, +} diff --git a/lua/custom/plugins/vim_cmake.lua b/lua/custom/plugins/vim_cmake.lua new file mode 100644 index 00000000..de316200 --- /dev/null +++ b/lua/custom/plugins/vim_cmake.lua @@ -0,0 +1,3 @@ +return { + 'cdelledonne/vim-cmake', +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 196f2c6d..b9052bed 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -13,6 +13,7 @@ return { dependencies = { -- Creates a beautiful debugger UI 'rcarriga/nvim-dap-ui', + 'theHamsta/nvim-dap-virtual-text', -- Required dependency for nvim-dap-ui 'nvim-neotest/nvim-nio', @@ -22,7 +23,7 @@ return { 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here - 'leoluz/nvim-dap-go', + -- 'leoluz/nvim-dap-go', }, keys = function(_, keys) local dap = require 'dap' @@ -57,13 +58,15 @@ return { -- You can provide additional configuration to the handlers, -- see mason-nvim-dap README for more information - handlers = {}, + + handlers = nil, -- 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', + 'codelldb', + 'js-debug-adapter', }, } @@ -101,5 +104,144 @@ return { detached = vim.fn.has 'win32' == 0, }, } + -- cpp + dap.adapters.cpp = { + type = 'server', + port = '${port}', + executable = { + command = vim.fn.exepath 'codelldb', + args = { '--port', '${port}' }, + }, + } + dap.configurations.cpp = { + { + name = 'LLDB: Launch', + type = 'codelldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + console = 'integratedTerminal', + }, + } + + -- rust + dap.configurations.rust = dap.configurations.cpp + + -- c + dap.configurations.c = dap.configurations.cpp + + -- js/ts + dap.adapters['pwa-node'] = { + type = 'server', + host = 'localhost', + port = '${port}', + executable = { + command = 'node', + -- 💀 Make sure to update this path to point to your installation + args = { vim.fn.stdpath 'data' .. '/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js', '${port}' }, + }, + } + dap.configurations.javascript = { + { + type = 'pwa-node', + request = 'launch', + name = 'Launch file', + program = '${file}', + cwd = '${workspaceFolder}', + }, + } + + dap.configurations.typescript = { + { + type = 'pwa-node', + request = 'launch', + name = 'Launch file', + program = '${file}', + cwd = '${workspaceFolder}', + }, + } + + -- debug our applications running on the browser. + --note: chrome has to be started with a remote debugging port INFO : google-chrome-stable --remote-debugging-port=9222 + -- dap.adapters.chrome = { + -- type = 'executable', + -- command = 'node', + -- args = { vim.fn.stdpath 'data' .. '/mason/packages/chrome-debug-adapter/out/src/chromeDebug.js' }, -- TODO adjust + -- } + -- + -- dap.configurations.javascriptreact = { -- change this to javascript if needed + -- { + -- type = 'chrome', + -- request = 'attach', + -- program = '${file}', + -- cwd = vim.fn.getcwd(), + -- sourceMaps = true, + -- protocol = 'inspector', + -- port = 9230, + -- webRoot = '${workspaceFolder}', + -- }, + -- } + -- + -- dap.configurations.typescriptreact = { -- change to typescript if needed + -- { + -- type = 'chrome', + -- request = 'attach', + -- program = '${file}', + -- cwd = vim.fn.getcwd(), + -- sourceMaps = true, + -- protocol = 'inspector', + -- port = 9230, + -- webRoot = '${workspaceFolder}', + -- }, + -- } + -- dap.configurations.javascriptreact = { + -- { + -- type = 'pwa-node', + -- request = 'launch', + -- name = 'Launch Next.js', + -- runtimeExecutable = 'pnpm', + -- runtimeArgs = { 'run', 'dev' }, + -- cwd = vim.fn.getcwd(), + -- sourceMaps = true, + -- protocol = 'inspector', + -- -- console = 'integratedTerminal', + -- port = 9230, + -- -- skipFiles = { '/**', 'node_modules/**/*.js' }, + -- }, + -- { + -- type = 'pwa-node', + -- request = 'attach', + -- name = 'Attach to Next.js', + -- processId = require('dap.utils').pick_process, + -- cwd = vim.fn.getcwd(), + -- sourceMaps = true, + -- protocol = 'inspector', + -- -- console = 'integratedTerminal', + -- port = 9230, + -- }, + -- } + -- + -- dap.configurations.typescriptreact = dap.configurations.javascriptreact + -- virtual text + require('nvim-dap-virtual-text').setup { + -- This just tries to mitigate the chance that I leak tokens here. Probably won't stop it from happening... + display_callback = function(variable) + local name = string.lower(variable.name) + local value = string.lower(variable.value) + if name:match 'secret' or name:match 'api' or value:match 'secret' or value:match 'api' then + return '*****' + end + + if #variable.value > 15 then + return ' ' .. string.sub(variable.value, 1, 15) .. '... ' + end + + return ' ' .. variable.value + end, + } end, } diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index 4bcc70f4..faf2ae00 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -8,6 +8,7 @@ return { opts = { on_attach = function(bufnr) local gitsigns = require 'gitsigns' + gitsigns.toggle_current_line_blame() local function map(mode, l, r, opts) opts = opts or {} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua deleted file mode 100644 index f126d68a..00000000 --- a/lua/kickstart/plugins/neo-tree.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Neo-tree is a Neovim plugin to browse the file system --- https://github.com/nvim-neo-tree/neo-tree.nvim - -return { - 'nvim-neo-tree/neo-tree.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended - 'MunifTanjim/nui.nvim', - }, - cmd = 'Neotree', - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal' }, - }, - opts = { - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, - }, - }, - }, -} diff --git a/vim-test.lua b/vim-test.lua new file mode 100644 index 00000000..3ace7bf0 --- /dev/null +++ b/vim-test.lua @@ -0,0 +1,11 @@ +return { + 'vim-test/vim-test', + dependencies = { + 'preservim/vimux', + }, + vim.keymap.set('n', 't', ':TestNearest'), + vim.keymap.set('n', 'T', ':TestFile'), + vim.keymap.set('n', 'm', ':TestSuite'), + vim.keymap.set('n', 'l', ':TestLast'), + vim.keymap.set('n', 'g', ':TestVisit'), +}