mirror of
https://github.com/mqttr/dotfiles.git
synced 2025-12-15 04:25:50 -06:00
450 lines
17 KiB
Lua
450 lines
17 KiB
Lua
-----------------------------
|
|
-- General Settings
|
|
-----------------------------
|
|
vim.g.mapleader = ' '
|
|
vim.g.maplocalleader = ' '
|
|
vim.g.have_nerd_font = true
|
|
|
|
-- Visual Things
|
|
vim.opt.cmdheight = 0 -- Currently looking for a solution for searching with / and ?
|
|
vim.opt.number = true
|
|
vim.opt.relativenumber = true
|
|
vim.opt.mouse = 'a'
|
|
vim.opt.showmode = false
|
|
|
|
-- Sync clipboard between OS and Neovim.
|
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
|
-- Remove this option if you want your OS clipboard to remain independent.
|
|
-- See `:help 'clipboard'`
|
|
-- It does get added to the @ register I believe?
|
|
vim.schedule(function()
|
|
vim.opt.clipboard = 'unnamedplus'
|
|
end)
|
|
|
|
-- Enable break indent
|
|
vim.opt.breakindent = true
|
|
-- Enable word break instead of character break
|
|
vim.opt.linebreak = true
|
|
|
|
-- Save undo history
|
|
vim.opt.undofile = true
|
|
|
|
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
|
|
vim.opt.ignorecase = true
|
|
vim.opt.smartcase = true
|
|
|
|
-- Keep signcolumn on by default
|
|
vim.opt.signcolumn = 'yes'
|
|
|
|
-- Decrease update time
|
|
vim.opt.updatetime = 250
|
|
|
|
-- Decrease mapped sequence wait time
|
|
-- Displays which-key popup sooner
|
|
vim.opt.timeoutlen = 200
|
|
|
|
-- Configure how new splits should be opened
|
|
vim.opt.splitright = true
|
|
vim.opt.splitbelow = true
|
|
|
|
-- Sets how neovim will display certain whitespace characters in the editor.
|
|
-- See `:help 'list'`
|
|
-- and `:help 'listchars'`
|
|
vim.opt.list = true
|
|
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
|
|
|
-- Preview substitutions live, as you type!
|
|
vim.opt.inccommand = 'split'
|
|
|
|
-- Hides special characters in markdown
|
|
vim.opt.conceallevel = 2
|
|
|
|
-- Show which line your cursor is on
|
|
vim.opt.cursorline = true
|
|
|
|
-- Spelling Correction
|
|
vim.opt.spell = true
|
|
-- vim.opt.spelllang = 'en'
|
|
|
|
-- Tabulation Stuffs
|
|
vim.opt.shiftwidth = 4
|
|
vim.opt.expandtab = true
|
|
|
|
-- Minimal number of screen lines to keep above and below the cursor.
|
|
vim.opt.scrolloff = 7
|
|
|
|
-----------------------------
|
|
-- Quality of Life Keybinds:
|
|
-----------------------------
|
|
|
|
vim.keymap.set('n', '<C-s>', '<cmd>w<CR>', { silent = true })
|
|
vim.keymap.set('i', '<C-s>', '<cmd>w<CR>', { silent = true })
|
|
|
|
--------------------
|
|
-- Quit Vim
|
|
vim.keymap.set('n', '<leader>qa', '<cmd>qa!<CR>', { desc = 'Force quit without saving'})
|
|
vim.keymap.set('n', '<leader>qx', '<cmd>xa!<CR>', { desc = 'Write to all then force quit'})
|
|
|
|
|
|
--------------------
|
|
-- Text Oriented
|
|
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
|
vim.keymap.set('v', 'R', 's')
|
|
|
|
--------------------
|
|
-- Movement
|
|
|
|
-- Faster Window Navigation
|
|
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { silent=true, desc = 'Move focus to the left window' })
|
|
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { silent=true, desc = 'Move focus to the right window' })
|
|
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { silent=true, desc = 'Move focus to the lower window' })
|
|
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { silent=true, desc = 'Move focus to the upper window' })
|
|
|
|
-- Terminal
|
|
-- or just use <C-\><C-n> to exit terminal mode
|
|
vim.keymap.set('t', '<C-x>', '<C-\\><C-n>', { silent=true, desc = 'Exit terminal mode' })
|
|
|
|
-- Skipping Sections
|
|
vim.keymap.set('n', '<C-Up>', 'zz20kzz', { silent=true, desc = 'Skip Large Sections' })
|
|
vim.keymap.set('n', '<C-Down>', 'zz20jzz', { silent=true, desc = 'Skip Large Sections' })
|
|
vim.keymap.set('i', '<C-Up>', '<ESC>2ka', { silent=true, desc = 'Skip Large Sections' })
|
|
vim.keymap.set('i', '<C-Down>', '<ESC>2ja', { silent=true, desc = 'Skip Large Sections' })
|
|
|
|
--------------------
|
|
-- Window Manipulation
|
|
|
|
vim.keymap.set('n', '<C-q>', '<CMD>q<CR>', { silent=true, desc='Close Window' })
|
|
|
|
--------------------
|
|
-- Weird Sh*t Fixes
|
|
vim.keymap.set('n', 's', '', {desc="[S]urround"}) -- Dunno but this is needed to stop some weird substitution thing
|
|
vim.keymap.set('n', 'm', 'q', {desc="Macro"})
|
|
vim.keymap.set('n', 'q', '') -- Record fights me so often
|
|
|
|
-- [[ Basic Autocommands ]]
|
|
-- See `:help lua-guide-autocommands`
|
|
|
|
-- Highlight when yanking (copying) text
|
|
-- Try it with `yap` in normal mode
|
|
-- See `:help vim.highlight.on_yank()`
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
desc = 'Highlight when yanking (copying) text',
|
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
|
callback = function()
|
|
vim.highlight.on_yank()
|
|
end,
|
|
})
|
|
|
|
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
|
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
|
|
if vim.v.shell_error ~= 0 then
|
|
error('Error cloning lazy.nvim:\n' .. out)
|
|
end
|
|
end ---@diagnostic disable-next-line: undefined-field
|
|
vim.opt.rtp:prepend(lazypath)
|
|
|
|
require('lazy').setup({
|
|
-- Was constantly fighting this. It get's it wrong istg ;-;
|
|
-- 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
|
|
|
|
-- 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 = '~' },
|
|
},
|
|
},
|
|
},
|
|
|
|
{ -- Shows Keybinds
|
|
'folke/which-key.nvim',
|
|
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
|
|
opts = {
|
|
icons = {
|
|
mappings = vim.g.have_nerd_font,
|
|
keys = vim.g.have_nerd_font and {} or {
|
|
Up = '<Up> ',
|
|
Down = '<Down> ',
|
|
Left = '<Left> ',
|
|
Right = '<Right> ',
|
|
C = '<C-…> ',
|
|
M = '<M-…> ',
|
|
D = '<D-…> ',
|
|
S = '<S-…> ',
|
|
CR = '<CR> ',
|
|
Esc = '<Esc> ',
|
|
ScrollWheelDown = '<ScrollWheelDown> ',
|
|
ScrollWheelUp = '<ScrollWheelUp> ',
|
|
NL = '<NL> ',
|
|
BS = '<BS> ',
|
|
Space = '<Space> ',
|
|
Tab = '<Tab> ',
|
|
F1 = '<F1>',
|
|
F2 = '<F2>',
|
|
F3 = '<F3>',
|
|
F4 = '<F4>',
|
|
F5 = '<F5>',
|
|
F6 = '<F6>',
|
|
F7 = '<F7>',
|
|
F8 = '<F8>',
|
|
F9 = '<F9>',
|
|
F10 = '<F10>',
|
|
F11 = '<F11>',
|
|
F12 = '<F12>',
|
|
},
|
|
},
|
|
|
|
-- Document existing key chains
|
|
spec = {
|
|
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
|
|
{ '<leader>d', group = '[D]iagnostic' },
|
|
{ '<leader>r', group = '[R]ename' },
|
|
{ '<leader>f', group = '[F]ind' },
|
|
{ '<leader>w', group = '[W]orkspace' },
|
|
{ '<leader>t', group = '[T]oggle' },
|
|
{ '<leader>q', group = 'Open quick [Q]uit menu' },
|
|
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
|
{ 's', group = '[S]urround' }
|
|
},
|
|
},
|
|
},
|
|
|
|
{ -- Fuzzy Finder (files, lsp, etc)
|
|
'nvim-telescope/telescope.nvim',
|
|
event = 'VimEnter',
|
|
branch = '0.1.x',
|
|
dependencies = {
|
|
'nvim-lua/plenary.nvim',
|
|
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
|
'nvim-telescope/telescope-fzf-native.nvim',
|
|
|
|
-- `build` is used to run some command when the plugin is installed/updated.
|
|
-- This is only run then, not every time Neovim starts up.
|
|
build = 'make',
|
|
|
|
-- `cond` is a condition used to determine whether this plugin should be
|
|
-- installed and loaded.
|
|
cond = function()
|
|
return vim.fn.executable 'make' == 1
|
|
end,
|
|
},
|
|
{ 'nvim-telescope/telescope-ui-select.nvim' },
|
|
|
|
-- Useful for getting pretty icons, but requires a Nerd Font.
|
|
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
|
|
},
|
|
config = function()
|
|
-- The easiest way to use Telescope, is to start by doing something like:
|
|
-- :Telescope help_tags
|
|
--
|
|
-- Two important keymaps to use while in Telescope are:
|
|
-- - Insert mode: <c-/>
|
|
-- - Normal mode: ?
|
|
--
|
|
-- [[ Configure Telescope ]]
|
|
-- See `:help telescope` and `:help telescope.setup()`
|
|
local actions = require('telescope.actions')
|
|
require('telescope').setup {
|
|
defaults = {
|
|
mappings = {
|
|
i = {
|
|
-- ['<c-enter>'] = 'to_fuzzy_refine'
|
|
['<esc>'] = actions.close
|
|
},
|
|
},
|
|
find_command = { 'rg', '--files', '--follow' }, -- or 'fd' with '--follow' if you use fd as the search tool
|
|
},
|
|
-- pickers = {}
|
|
extensions = {
|
|
['ui-select'] = {
|
|
require('telescope.themes').get_dropdown(),
|
|
},
|
|
},
|
|
}
|
|
|
|
-- Enable Telescope extensions if they are installed
|
|
pcall(require('telescope').load_extension, 'fzf')
|
|
pcall(require('telescope').load_extension, 'ui-select')
|
|
|
|
-- See `:help telescope.builtin`
|
|
local builtin = require 'telescope.builtin'
|
|
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = '[F]ind [H]elp' })
|
|
vim.keymap.set('n', '<leader>fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' })
|
|
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = '[F]ind [F]iles' })
|
|
vim.keymap.set('n', '<leader>fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' })
|
|
vim.keymap.set('n', '<leader>fw', builtin.grep_string, { desc = '[F]ind current [W]ord' })
|
|
vim.keymap.set('n', '<leader>fg', function()
|
|
require('telescope.builtin').live_grep {
|
|
additional_args = function()
|
|
return { "--follow" }
|
|
end,
|
|
}
|
|
end, { desc = '[F]ind by [G]rep' })
|
|
vim.keymap.set('n', '<leader>fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' })
|
|
vim.keymap.set('n', '<leader>df', builtin.diagnostics, { desc = '[D]iagnostic [F]ind Via Telescope' })
|
|
vim.keymap.set('n', '<leader>fr', builtin.resume, { desc = '[F]ind [R]esume' })
|
|
vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' })
|
|
vim.keymap.set('n', '<leader><leader>', '<leader>fg', { desc = '[ ] Find Grep' })
|
|
|
|
vim.keymap.set('n', '<C-f>', function()
|
|
builtin.current_buffer_fuzzy_find({
|
|
winblend = 10,
|
|
previewer = false,
|
|
})
|
|
end, { desc = '' })
|
|
|
|
vim.keymap.set('n', '<leader>fb', function()
|
|
builtin.live_grep {
|
|
grep_open_files = true,
|
|
prompt_title = 'Live Grep in Open Files',
|
|
}
|
|
end, { desc = '[F]ind in [B]uffers' })
|
|
|
|
-- Shortcut for searching your Neovim configuration files
|
|
vim.keymap.set('n', '<leader>fn', function()
|
|
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
|
end, { desc = '[F]ind [N]eovim files' })
|
|
end,
|
|
},
|
|
|
|
{ -- You can easily change to a different colorscheme.
|
|
-- Change the name of the colorscheme plugin below, and then
|
|
-- 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',
|
|
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'
|
|
|
|
-- You can configure highlights by doing something like:
|
|
vim.cmd.hi 'Comment gui=none'
|
|
end,
|
|
},
|
|
require 'plugins.lsp',
|
|
require 'plugins.autopairs',
|
|
require 'plugins.neo-tree',
|
|
require 'plugins.gitsigns',
|
|
require 'plugins.barbar',
|
|
require 'plugins.terminal',
|
|
require 'plugins.venn',
|
|
require 'plugins.blinkcmp',
|
|
-- require 'plugins.debug',
|
|
-- Highlight todo, notes, etc in comments
|
|
{
|
|
"OXY2DEV/markview.nvim",
|
|
lazy = false, -- Recommended
|
|
-- ft = "markdown" -- If you decide to lazy-load anyway
|
|
|
|
dependencies = {
|
|
"nvim-treesitter/nvim-treesitter",
|
|
"nvim-tree/nvim-web-devicons"
|
|
}
|
|
},
|
|
{
|
|
'folke/todo-comments.nvim',
|
|
event = 'VimEnter',
|
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
|
opts = { signs = false }
|
|
},
|
|
{ -- Collection of various small independent plugins/modules
|
|
'echasnovski/mini.nvim',
|
|
config = function()
|
|
-- Better Around/Inside textobjects
|
|
--
|
|
-- Examples:
|
|
-- - va) - [V]isually select [A]round [)]paren
|
|
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
|
|
-- - ci' - [C]hange [I]nside [']quote
|
|
require('mini.ai').setup { n_lines = 500 }
|
|
|
|
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
|
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
|
|
-- - sd' - [S]urround [D]elete [']quotes
|
|
-- - sr)' - [S]urround [R]eplace [)] [']
|
|
require('mini.surround').setup()
|
|
|
|
-- Simple and easy statusline.
|
|
-- You could remove this setup call if you don't like it,
|
|
-- and try some other statusline plugin
|
|
local statusline = require 'mini.statusline'
|
|
-- set use_icons to true if you have a Nerd Font
|
|
statusline.setup { use_icons = vim.g.have_nerd_font }
|
|
|
|
-- You can configure sections in the statusline by overriding their
|
|
-- default behavior. For example, here we set the section for
|
|
-- cursor location to LINE:COLUMN
|
|
---@diagnostic disable-next-line: duplicate-set-field
|
|
statusline.section_location = function()
|
|
return '%2l:%-2v'
|
|
end
|
|
-- https://github.com/echasnovski/mini.nvim
|
|
end,
|
|
},
|
|
{ -- Highlight, edit, and navigate code
|
|
'nvim-treesitter/nvim-treesitter',
|
|
build = ':TSUpdate',
|
|
main = 'nvim-treesitter.configs',
|
|
opts = {
|
|
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'query', 'vim', 'vimdoc' },
|
|
-- Autoinstall languages that are not installed
|
|
auto_install = true,
|
|
highlight = {
|
|
enable = true,
|
|
-- 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' },
|
|
disable = { 'latex' }
|
|
},
|
|
indent = { enable = true, disable = { 'ruby' } },
|
|
},
|
|
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
|
|
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
|
|
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
|
},
|
|
{
|
|
'VonHeikemen/fine-cmdline.nvim',
|
|
dependencies = {
|
|
{'MunifTanjim/nui.nvim'}
|
|
},
|
|
cmdline = {
|
|
smart_history = true
|
|
},
|
|
config = function()
|
|
vim.api.nvim_set_keymap('n', ':', '<cmd>FineCmdline<CR>', {noremap = true})
|
|
end
|
|
},
|
|
},
|
|
{
|
|
ui = {
|
|
icons = vim.g.have_nerd_font and {} or {
|
|
cmd = '⌘',
|
|
config = '🛠',
|
|
event = '📅',
|
|
ft = '📂',
|
|
init = '⚙',
|
|
keys = '🗝',
|
|
plugin = '🔌',
|
|
runtime = '💻',
|
|
require = '🌙',
|
|
source = '📄',
|
|
start = '🚀',
|
|
task = '📌',
|
|
lazy = '💤 ',
|
|
},
|
|
},
|
|
})
|
|
|
|
require('config.lsp')
|