personal configuations

merge conflicts adjusted
This commit is contained in:
ngorana 2024-08-09 11:10:39 +01:00
parent 1860184830
commit 373c8dc5d3
12 changed files with 318 additions and 144 deletions

163
init.lua
View File

@ -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:
- <escape key>
- :
- Tutor
- <enter key>
(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 "<space>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 <space> 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', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps
vim.keymap.set('n', '<leader>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 <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
@ -176,10 +96,10 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
@ -369,7 +289,7 @@ require('lazy').setup({
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>ss', builtin.find_files, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>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

View File

@ -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', '<leader>a', function()
harpoon:list():add()
end, { desc = 'Add Buffer to Harpoon' })
vim.keymap.set('n', '<C-e>', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
vim.keymap.set('n', '<leader>1', function()
harpoon:list():select(1)
end, { desc = 'First Buffer in Harpoon' })
vim.keymap.set('n', '<leader>2', function()
harpoon:list():select(2)
end, { desc = 'Second Buffer in Harpoon' })
vim.keymap.set('n', '<leader>3', function()
harpoon:list():select(3)
end, { desc = 'Third Buffer in Harpoon' })
vim.keymap.set('n', '<leader>4', function()
harpoon:list():select(4)
end, { desc = 'Fourth Buffer in Harpoon' })
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set('n', '<C-S-P>', function()
harpoon:list():prev()
end)
vim.keymap.set('n', '<C-S-N>', function()
harpoon:list():next()
end)
end,
}

View File

@ -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,
}

View File

@ -0,0 +1,24 @@
return {
{
'stevearc/oil.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require('oil').setup {
columns = { 'icon' },
keymaps = {
['<C-h>'] = false,
['<M-h>'] = 'actions.select_vsplit',
},
view_options = {
show_hidden = true,
},
}
-- Open parent directory in current window
vim.keymap.set('n', '<leader>n', '<CMD>Oil<CR>', { desc = 'Open parent directory' })
-- Open parent directory in floating window
vim.keymap.set('n', '<space>-', require('oil').toggle_float)
end,
},
}

View File

@ -0,0 +1,6 @@
return {
'mbbill/undotree',
config = function()
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
end,
}

View File

@ -0,0 +1,11 @@
return {
'vim-test/vim-test',
dependencies = {
'preservim/vimux',
},
vim.keymap.set('n', '<leader>t', ':TestNearest<CR>'),
vim.keymap.set('n', '<leader>T', ':TestFile<CR>'),
vim.keymap.set('n', '<leader>m', ':TestSuite<CR>'),
vim.keymap.set('n', '<leader>l', ':TestLast<CR>'),
vim.keymap.set('n', '<leader>g', ':TestVisit<CR>'),
}

View File

@ -0,0 +1,18 @@
return {
'christoomey/vim-tmux-navigator',
lazy = false,
cmd = {
'TmuxNavigateLeft',
'TmuxNavigateDown',
'TmuxNavigateUp',
'TmuxNavigateRight',
'TmuxNavigatePrevious',
},
keys = {
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' },
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
{ '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' },
},
}

View File

@ -0,0 +1,3 @@
return {
'cdelledonne/vim-cmake',
}

View File

@ -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_internals>/**', '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,
}

View File

@ -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 {}

View File

@ -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<CR>', desc = 'NeoTree reveal' },
},
opts = {
filesystem = {
window = {
mappings = {
['\\'] = 'close_window',
},
},
},
},
}

11
vim-test.lua Normal file
View File

@ -0,0 +1,11 @@
return {
'vim-test/vim-test',
dependencies = {
'preservim/vimux',
},
vim.keymap.set('n', '<leader>t', ':TestNearest<CR>'),
vim.keymap.set('n', '<leader>T', ':TestFile<CR>'),
vim.keymap.set('n', '<leader>m', ':TestSuite<CR>'),
vim.keymap.set('n', '<leader>l', ':TestLast<CR>'),
vim.keymap.set('n', '<leader>g', ':TestVisit<CR>'),
}