improving startup time by using lazy loading or filetype loading

This commit is contained in:
Jeremie Fraeys 2024-07-21 20:57:00 -04:00
parent bdb655c5a1
commit 7f1b34fd6f
62 changed files with 1285 additions and 561 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,13 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="dict.database" />
<option value="search_engine" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,6 +1,11 @@
column_width = 160
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
call_parentheses = "Always"
quote_style = "AutoPreferSingle"
call_parentheses = "None"
collapse_simple_statement = "Never"
[sort_requires]
enabled = false

5
after/ftplugin/c.lua Normal file
View File

@ -0,0 +1,5 @@
vim.opt_local.expandtab = true
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 10
vim.opt_local.softtabstop = 4
vim.opt_local.formatoptions:remove('o')

View File

@ -0,0 +1 @@
vim.opt_local.fixeol = false

View File

@ -0,0 +1,2 @@
vim.opt_local.expandtab = true
vim.opt_local.shiftwidth = 2

10
after/ftplugin/go.lua Normal file
View File

@ -0,0 +1,10 @@
-- Set buffer-local options for Go files
vim.opt_local.expandtab = true
vim.opt_local.commentstring = '// %s'
vim.opt_local.comments = 's1:/*,mb:*,ex:*/,://'
-- Define a key mapping to trigger Go debugging
vim.keymap.set('n', '<leader>td', function()
require('dap-go').debug_test()
end, { buffer = 0 }) -- Set buffer-local key mapping

10
after/ftplugin/lua.lua Normal file
View File

@ -0,0 +1,10 @@
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.expandtab = true
vim.opt_local.formatoptions:remove('o')
vim.opt_local.commentstring = '-- %s'
vim.opt_local.colorcolumn = '120'

1
after/ftplugin/make.lua Normal file
View File

@ -0,0 +1 @@

5
after/ftplugin/ocaml.lua Normal file
View File

@ -0,0 +1,5 @@
vim.opt.shiftwidth = 2
-- vim.keymap.set('n', '<space>cp', require('ocaml.mappings').dune_promote_file, { buffer = 0 })
--

View File

@ -0,0 +1,9 @@
vim.opt_local.expandtab = true
vim.opt_local.commentstring = '# %s'
vim.opt_local.smarttab = true
vim.opt_local.shiftwidth = 4
vim.opt_local.tabstop = 4
vim.opt_local.softtabstop = 4
vim.opt_local.fileformat = 'unix'
vim.opt_local.textwidth = 79
vim.opt_local.colorcolumn = '80'

15
after/ftplugin/rust.lua Normal file
View File

@ -0,0 +1,15 @@
-- Set buffer-local options for Rust files
vim.opt_local.expandtab = true
vim.opt_local.autoindent = true
vim.opt_local.smartindent = true
vim.opt_local.shiftwidth = 4
vim.opt_local.tabstop = 4
vim.opt_local.softtabstop = 4
vim.opt_local.textwidth = 80
vim.opt_local.colorcolumn = '80'
-- Define key mappings or other configurations specific to Rust
-- For example:
vim.keymap.set('n', '<leader>r', '<CMD>Cargo run<CR>', { desc = 'Run the current Rust project', noremap = true })
vim.keymap.set('n', '<leader>c', '<CMD>Cargo check<CR>', { desc = 'Check the current Rust project', noremap = true })

7
after/ftplugin/sh.lua Normal file
View File

@ -0,0 +1,7 @@
vim.opt_local.expandtab = true
vim.opt_local.shiftwidth = 2
vim.opt_local.softtabstop = 2
vim.opt_local.tabstop = 2
vim.opt_local.textwidth = 80
vim.opt_local.syntax = enable

1
after/ftplugin/sql.lua Normal file
View File

@ -0,0 +1 @@
vim.opt_local.commentstring = '-- %s'

0
after/ftplugin/yaml.lua Normal file
View File

View File

@ -1,24 +0,0 @@
================================================================================
INTRODUCTION *kickstart.nvim*
Kickstart.nvim is a project to help you get started on your neovim journey.
*kickstart-is-not*
It is not:
- Complete framework for every plugin under the sun
- Place to add every plugin that could ever be useful
*kickstart-is*
It is:
- Somewhere that has a good start for the most common "IDE" type features:
- autocompletion
- goto-definition
- find references
- fuzzy finding
- and hinting at what more can be done :)
- A place to _kickstart_ your journey.
- You should fork this project and use/modify it so that it matches your
style and preferences. If you don't want to do that, there are probably
other projects that would fit much better for you (and that's great!)!
vim:tw=78:ts=8:ft=help:norl:

View File

@ -1,3 +0,0 @@
kickstart-is kickstart.txt /*kickstart-is*
kickstart-is-not kickstart.txt /*kickstart-is-not*
kickstart.nvim kickstart.txt /*kickstart.nvim*

View File

@ -1,44 +1,26 @@
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Install package manager
-- https://github.com/folke/lazy.nvim
-- Check Lua documentation for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
}
})
end
vim.opt.rtp:prepend(lazypath)
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
local opts = {
git = { log = { '--since=3 days ago' } },
ui = { custom_keys = { false } },
checker = { enabled = false },
colorscheme = "monokai",
}
require('lazy').setup({
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
-- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth',
{
import = 'custom.plugins',
exclude = 'custom.plugins.mason',
},
}, opts)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
require('config.lazy')
require('config.autocmds')
require('config.options')
require('config.mappings')
require('config.utils')
require('config.themes')
vim.cmd('filetype plugin on')

66
lua/config/autocmds.lua Executable file
View File

@ -0,0 +1,66 @@
-- Auto-format on save
vim.cmd [[
augroup FormatOnSave
autocmd!
autocmd BufWritePre * lua vim.lsp.buf.format({ async = false })
augroup END
]]
-- Augroup for Highlight on yank
vim.cmd([[
augroup YankHighlight
autocmd!
autocmd TextYankPost * lua vim.highlight.on_yank()
augroup END
]])
-- Remove trailing whitespace
vim.cmd([[
augroup RemoveTrailingWhitespace
autocmd!
autocmd BufWritePre * %s/\s\+$//e
augroup END
]])
-- Append newline at EOF, excluding YAML files
vim.cmd([[
augroup append_newline_at_eof
autocmd!
autocmd BufWritePre * silent! if !empty(getline('$')) && getline('$') !~# '\n$' && &filetype != 'yaml' | call append(line('$'), '') | endif
augroup END
]])
local function augroup(name)
return vim.api.nvim_create_augroup('lazyvim_' .. name, { clear = true })
end
vim.api.nvim_create_autocmd('VimEnter', {
group = augroup('autoupdate'),
callback = function()
if require('lazy.status').has_updates() then
require('lazy').update({ show = false })
end
end,
})
vim.api.nvim_create_autocmd('User', {
pattern = 'LazyCheck',
-- pattern = "LazyVimStarted",
desc = 'Update lazy.nvim plugins',
callback = function(event)
local start_time = os.clock()
require('lazy').sync({ wait = false, show = false })
local end_time = os.clock()
print('Lazy plugins synced in ' .. (end_time - start_time) * 1000 .. 'ms')
print(vim.print(event))
end,
})
-- Automatically start insert mode in terminal buffers
vim.cmd([[
autocmd TermOpen * startinsert
autocmd TermOpen * setlocal nonumber norelativenumber
autocmd TermOpen * normal! G
autocmd TermOpen * tnoremap <Esc> <C-\><C-n>
]])

37
lua/config/lazy.lua Executable file
View File

@ -0,0 +1,37 @@
local opts = {
git = { log = { '--since=3 days ago' } },
ui = { custom_keys = { false } },
colors = { themes = { 'monokai' } },
checker = {
enabled = true,
-- notify = false,
},
performance = {
rtp = {
disabled_plugins = {
'gzip',
'tarPlugin',
'tohtml',
'tutor',
'zipPlugin',
},
},
},
change_detection = {
notify = false,
},
}
require('lazy').setup({
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
-- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth',
{
import = 'custom.plugins',
exclude = 'custom.plugins.mason',
},
}, opts)

View File

@ -1,107 +1,122 @@
-- [[ Basic Keymaps ]]
local utils = require('config.utils')
-- Basic Keymaps
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
-- vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
vim.keymap.set('n', '<C-c>', '<ESC><ESC>', { silent = true })
-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", {
expr = true, silent = true
})
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", {
-- Unmap the 'gp' key for previous word
expr = true,
silent = true
})
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Move lines
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { silent = true })
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { silent = true })
vim.keymap.set('n', '>', '>gv', { silent = true })
vim.keymap.set('n', '<', '<gv', { silent = true })
vim.keymap.set('n', 'J', "mzj`z")
vim.keymap.set('n', '<C-d>', "<C-d>zz", { desc = "Half Page Jumping Up" })
vim.keymap.set('n', '<C-u>', "<C-u>zz", { desc = "Half Page Jumping Down" })
-- Keep search line in the middle
-- Miscellaneous Navigation Keymaps
vim.keymap.set('n', 'J', 'mzj`z')
vim.keymap.set('n', '<c-d>', '<C-d>zz', { desc = 'Half Page Jumping Up' })
vim.keymap.set('n', '<c-u>', '<C-u>zz', { desc = 'Half Page Jumping Down' })
vim.keymap.set('n', 'n', 'nzzzv', { silent = true })
vim.keymap.set('n', 'N', 'Nzzzv', { silent = true })
-- Unmap the 'p' key for previous word
vim.api.nvim_set_keymap('n', 'gp', '<Nop>', { noremap = true, silent = true })
vim.keymap.set('n', '<C-k>', '<cmd>cnext<CR>zz')
vim.keymap.set('n', '<C-j>', '<cmd>cprev<CR>zz')
vim.keymap.set('n', '<leader>k', '<cmd>lnext<CR>zz', { desc = 'Quick Fix Nav Up' })
vim.keymap.set('n', '<leader>j', '<cmd>lprev<CR>zz', { desc = 'Quick Fix Nav Down' })
-- Quick fix navigation
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Quick Fix Nav Up" })
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Quick Fix Nav Down" })
-- Buffer Navigation Keymaps
vim.keymap.set('n', '<leader>bn', '<cmd>bnext<CR>zz', { desc = 'Quick Nav Buf Next' })
vim.keymap.set('n', '<leader>bp', '<cmd>bprev<CR>zz', { desc = 'Quick Nav Buf Prev' })
vim.keymap.set('n', '<leader>bd', '<cmd>bdelete<CR>', { desc = 'Quick Nav Buf Delete' })
vim.keymap.set('n', '<leader>bs', '<cmd>split<CR>', { desc = 'Openn Buf Horizontal Split' })
vim.keymap.set('n', '<leader>bv', '<cmd>vsp<CR>', { desc = 'Open Buf Vertical Split' })
vim.keymap.set('n', '<leader>bt', '<cmd>terminal<CR>')
-- Copy from plus register
vim.keymap.set({ 'n', 'v' }, '<leader>y', "\"+y", { desc = "Copy to + register" })
vim.keymap.set('n', '<leader>Y', "\"+Y")
-- Editing Keymaps
vim.keymap.set('x', '<leader>p', [["_dP"]], { desc = 'Paste without register' })
vim.keymap.set({ 'n', 'v' }, '<leader>d', [["_d"]], { desc = 'Delete without register' })
vim.keymap.set({ 'n', 'v' }, '<leader>y', '"+y', { desc = 'Copy to + register' })
vim.keymap.set('n', '<leader>Y', '"+Y')
-- replace current word in current scope
vim.keymap.set(
'n',
'<leader>r',
':%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>',
{ desc = '[R]eplace Current Word in Current Scope' }
)
-- replace current word in file scope
vim.keymap.set(
'n',
'<leader>R',
':%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>',
{ desc = '[R]eplace Current Word in File Scope' }
)
-- Replace current word
vim.keymap.set("n", "<leader>r", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
{ desc = "[R]eplace Current Word" })
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { desc = "Set Current File to Executable", silent = true })
-- Open vertical split pane
-- [ telescope keymaps]
-- File Management Keymaps
vim.keymap.set('n', '<C-f>', '<cmd>silent !tmux neww $HOME/.local/bin/tmux_sessionizer<CR>', { desc = 'Open Session' })
vim.keymap.set('n', '<leader>x', '<cmd>!chmod +x %<CR>', { desc = 'Set Current File to Executable', silent = true })
-- Telescope Keymaps
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
-- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes'))
require('telescope.builtin').current_buffer_fuzzy_find(
require('telescope.themes').get_dropdown({ winblend = 10, previewer = false })
)
end, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>gb', require('telescope.builtin').git_branches, { desc = 'Search [G]it [B]ranches' })
vim.keymap.set('n', '<leader>gc', require('telescope.builtin').git_commits, { desc = 'Search [G]it [C]ommits' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sp', function()
require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") })
end, { desc = '[S]search [P]roject' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' })
-- [ tree-sitter keymaps ]
vim.keymap.set({ 'n', 'v' }, '<leader>sh', function()
local query = utils.get_search_query()
require('telescope.builtin').help_tags({ search = query, initial_mode = 'insert', default_text = query })
end, { desc = '[S]earch [H]elp' })
vim.keymap.set({ 'n', 'v' }, '<leader>sw', function()
local query = utils.get_search_query()
require('telescope.builtin').grep_string({ search = query, initial_mode = 'insert', default_text = query })
end, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sp', function()
require('telescope.builtin').grep_string({ search = vim.fn.input('Grep Search > ') })
end, { desc = '[S]search [P]roject' })
vim.keymap.set('n', '<leader>sG', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sg', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
-- Tree-sitter Keymaps
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
-- vim.keymap.set('n', '<leader>vd', function()
-- vim.diagnostic.setloclist()
-- vim.cmd('lopen')
-- end, { desc = 'Open the diagnostics location list' })
-- Open the diagnostics location list
vim.keymap.set('n', '<leader>q', function()
vim.diagnostic.setloclist()
vim.cmd('lopen')
end, {
noremap = true,
silent = true,
expr = false,
desc = 'Open the diagnostics location list'
})
-- Refactoring Keymaps
-- vim.keymap.set({ "x" }, "<leader>re", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Function" })
-- vim.keymap.set({ "x" }, "<leader>rf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Function To File" })
-- vim.keymap.set({ "x" }, "<leader>rv", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Variable')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Variable" })
-- vim.keymap.set({ "n" }, "<leader>rI", [[<Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Inline Variable" })
-- vim.keymap.set({ "n", "x" }, "<leader>ri", [[<Esc><Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Inline Variable" })
--
-- vim.keymap.set({ "n" }, "<leader>rb", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Block')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Block" })
-- vim.keymap.set({ "n" }, "<leader>rbf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Block To File')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Block To File" })
-- Close the diagnostics location list
vim.keymap.set('n', '<leader>qq', function()
vim.cmd('lclose')
end, {
noremap = true,
silent = true,
expr = false,
desc = 'Close the diagnostics location list'
})
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})

View File

@ -3,11 +3,20 @@ local g = vim.g
local opts = {
-- Change cursor in insert mode
guicursor = "",
guicursor = '',
-- set terminal tab title
title = true,
titlelen = 0,
-- titlestring = 'nvim %t (%-15.25F)%a%r%m',
titlestring = 'nvim %t (%-15.25f)%a%r%m',
-- Make line numbers default
relativenumber = true,
--Enable noshowmode
showmode = false,
-- Enable break indent
breakindent = true,
@ -16,7 +25,6 @@ local opts = {
softtabstop = 4,
shiftwidth = 4,
expandtab = true,
smartindent = true,
-- Disable line wrap
wrap = false,
@ -24,7 +32,7 @@ local opts = {
-- Save undo history
swapfile = false,
backup = false,
undodir = vim.fn.stdpath("data") .. "/site/undodir",
undodir = vim.fn.stdpath('data') .. '/site/undodir',
undofile = true,
-- Searching Configuration
@ -45,7 +53,6 @@ local opts = {
-- NOTE: You should make sure your terminal supports this
termguicolors = true,
scrolloff = 10,
colorcolumn = "80",
pyxversion = 3,
}
@ -64,31 +71,31 @@ end
-- Disable built-in plugins
local disabled_built_ins = {
"2html_plugin",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"matchit",
'2html_plugin',
'getscript',
'getscriptPlugin',
'gzip',
'logipat',
'matchit',
-- "netrw",
"netrwFileHandlers",
"loaded_remote_plugins",
"loaded_tutor_mode_plugin",
'netrwFileHandlers',
'loaded_remote_plugins',
'loaded_tutor_mode_plugin',
-- "netrwPlugin",
-- "netrwSettings",
"rrhelper",
"spellfile_plugin",
"tar",
"tarPlugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"matchparen",
'rrhelper',
'spellfile_plugin',
'tar',
'tarPlugin',
'vimball',
'vimballPlugin',
'zip',
'zipPlugin',
'matchparen',
}
for _, plugin in pairs(disabled_built_ins) do
g["loaded_" .. plugin] = 1
g['loaded_' .. plugin] = 1
end
-- Improve Neovim startup
@ -107,13 +114,14 @@ for k, v in pairs(global_let_opts) do
g[k] = v
end
opt.formatoptions = "l"
opt.formatoptions = 'l'
opt.formatoptions = opt.formatoptions
- "a" -- Auto formatting is BAD.
- "t" -- Don't auto format my code. I got linters for that.
+ "c" -- In general, I like it when comments respect textwidth
- "o" -- O and o, don't continue comments
+ "r" -- But do continue when pressing enter.
+ "n" -- Indent past the formatlistpat, not underneath it.
+ "j" -- Auto-remove comments if possible.
- "2" -- I'm not in gradeschool anymore
- 'a' -- Auto formatting is BAD.
- 't' -- Don't auto format my code. I got linters for that.
+ 'c' -- In general, I like it when comments respect textwidth
- 'o' -- O and o, don't continue comments
+ 'r' -- But do continue when pressing enter.
+ 'n' -- Indent past the formatlistpat, not underneath it.
+ 'j' -- Auto-remove comments if possible.
- '2' -- I'm not in gradeschool anymore

View File

@ -1,8 +0,0 @@
-- return {
-- Theme inspired by Atom
-- 'navarasu/onedark.nvim',
-- priority = 1000,
-- config = function()
-- vim.cmd.colorscheme 'onedark'
-- end,
-- },

View File

@ -1 +1,23 @@
return {
-- Function to get the current visual selection
get_visual_selection = function()
vim.cmd 'noau normal! "vy"'
local text = vim.fn.getreg 'v'
vim.fn.setreg('v', {})
text = string.gsub(text, '\n', '')
if #text > 0 then
return text
else
return ''
end
end,
-- Function to get the current search query
get_search_query = function()
local word_under_cursor = vim.fn.expand '<cword>'
local visual_selection = require('config.utils').get_visual_selection()
return visual_selection ~= '' and visual_selection or word_under_cursor
end,
}

View File

@ -0,0 +1,19 @@
return {
'f-person/auto-dark-mode.nvim',
event = 'VimEnter', -- Lazy load on VimEnter event
opts = {
update_interval = 1000, -- Check for mode change every second
set_dark_mode = function()
vim.cmd('colorscheme monokai')
vim.cmd('set background=dark') -- Ensure the background is set correctly
end,
set_light_mode = function()
vim.cmd('colorscheme solarized')
vim.cmd('set background=light')
end,
},
config = function(_, opts)
require('auto-dark-mode').setup(opts)
end
}

View File

@ -1,15 +1,13 @@
return {
"windwp/nvim-autopairs",
-- Optional dependency
'windwp/nvim-autopairs',
dependencies = { 'hrsh7th/nvim-cmp' },
event = 'InsertEnter',
config = function()
require("nvim-autopairs").setup {}
require('nvim-autopairs').setup({})
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}

View File

@ -11,35 +11,45 @@ return {
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
-- Optional sources
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
},
event = { 'InsertEnter', 'CmdlineEnter' },
config = function()
-- See `:help cmp`
-- Set completion options
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
-- Lazy load snippets from friendly-snippets
require('luasnip.loaders.from_vscode').lazy_load()
local cmp = require 'cmp'
local luasnip = require 'luasnip'
luasnip.config.setup {}
-- Import required modules
local cmp = require('cmp')
local luasnip = require('luasnip')
local select_opts = { behavior = cmp.SelectBehavior.Select }
-- Setup luasnip
luasnip.config.setup({})
cmp.setup {
-- Setup nvim-cmp
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
sources = {
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lsp', keyword_length = 1 },
{ name = 'buffer', keyword_length = 3 },
{ name = 'luasnip', keyword_length = 2 },
},
}),
window = {
documentation = cmp.config.window.bordered()
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { 'menu', 'abbr', 'kind' },
fields = { 'abbr', 'kind', 'menu' },
format = function(entry, item)
local menu_icon = {
nvim_lsp = 'λ',
@ -47,72 +57,52 @@ return {
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
item.menu = menu_icon[entry.source.name] or entry.source.name
return item
end,
},
mapping = cmp.mapping.preset.insert {
mapping = cmp.mapping.preset.insert({
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-l>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
['<C-h>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
}
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
text = opts.text,
numhl = ''
})
end
sign({ name = 'DiagnosticSignError', text = '' })
sign({ name = 'DiagnosticSignWarn', text = '' })
sign({ name = 'DiagnosticSignHint', text = '' })
sign({ name = 'DiagnosticSignInfo', text = '»' })
vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
float = {
border = 'rounded',
source = 'always',
},
['<C-e>'] = cmp.mapping.abort(),
}),
})
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
vim.lsp.handlers.hover,
{ border = 'rounded' }
)
-- Additional luasnip configuration
luasnip.config.set_config({
history = true,
updateevents = 'TextChanged,TextChangedI',
})
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{ border = 'rounded' }
)
-- Setup for SQL filetype with vim-dadbod-completion
cmp.setup.filetype('sql', {
sources = cmp.config.sources({
{ name = 'vim-dadbod-completion' },
{ name = 'buffer' },
}),
})
end,
}

View File

@ -1,5 +1,5 @@
return {
'numToStr/Comment.nvim',
opts = {},
lazy = false
}

19
lua/custom/plugins/copilot.lua Normal file → Executable file
View File

@ -1,3 +1,20 @@
return {
'github/copilot.vim',
'zbirenbaum/copilot.lua',
cmd = 'Copilot',
event = 'InsertEnter',
opts = {
suggestion = {
auto_trigger = true,
filetypes = {
['.'] = true,
},
keymap = {
accept_word = '<M-k>',
accept_line = '<M-j>',
next = 'M-[',
previous = 'M-]',
},
},
},
}

14
lua/custom/plugins/dadbod.lua Executable file
View File

@ -0,0 +1,14 @@
return {
'tpope/vim-dadbod',
dependencies = {
'kristijanhusak/vim-dadbod-ui',
'kristijanhusak/vim-dadbod-completion',
},
keys = {
{ '<leader>du', '<cmd>DBUIToggle<cr>', { desc = 'Toggle dadbod', noremap = true } },
},
init = function()
vim.g.db_ui_use_nerd_fonts = 1
end,
}

117
lua/custom/plugins/dap.lua Executable file
View File

@ -0,0 +1,117 @@
return {
-- Add the nvim-dap related plugins
{
'mfussenegger/nvim-dap',
dependencies = {
{ 'rcarriga/nvim-dap-ui', opt = true, cmd = 'DapUI' },
{ 'nvim-neotest/nvim-nio', opt = true, cmd = 'Neotest' },
{ 'theHamsta/nvim-dap-virtual-text', opt = true, ft = { 'python', 'go', 'rust' } },
{ 'mfussenegger/nvim-dap-python', opt = true, ft = 'python' },
{ 'leoluz/nvim-dap-go', opt = true, ft = 'go' },
{ 'simrat39/rust-tools.nvim', opt = true, ft = 'rust' },
'williamboman/mason.nvim', -- Mason for managing external tools
'williamboman/mason-lspconfig.nvim'
},
config = function()
local dap = require('dap')
local dapui = require('dapui')
local dap_virtual_text = require('nvim-dap-virtual-text')
local mason_registry = require('mason-registry')
-- Initialize dap-ui
dapui.setup()
-- Initialize dap-virtual-text
dap_virtual_text.setup()
-- Keybindings
vim.api.nvim_set_keymap('n', '<leader>dc', ':lua require"dap".continue()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ds', ':lua require"dap".step_over()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>di', ':lua require"dap".step_into()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>do', ':lua require"dap".step_out()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>db', ':lua require"dap".toggle_breakpoint()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>dr', ':lua require"dap".repl.open()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>du', ':lua require"dapui".toggle()<CR>', { noremap = true, silent = true })
-- DAP Python
local function get_python_path()
local cwd = vim.fn.getcwd()
if vim.env.VIRTUAL_ENV then
return vim.env.VIRTUAL_ENV .. '/bin/python'
elseif vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
return cwd .. '/.venv/bin/python'
else
return 'python'
end
end
require('dap-python').setup(get_python_path())
-- DAP Go
require('dap-go').setup()
-- DAP Rust
local rust_tools = require('rust-tools')
-- Ensure codelldb is installed via Mason
local codelldb_package = mason_registry.get_package('codelldb')
local codelldb_path = codelldb_package:get_install_path()
local codelldb_adapter = codelldb_path .. '/extension/adapter/codelldb'
local codelldb_lib = codelldb_path .. '/extension/lldb/lib/liblldb.so'
rust_tools.setup({
tools = {
autoSetHints = true,
inlay_hints = {
show_parameter_hints = true,
parameter_hints_prefix = "<- ",
other_hints_prefix = "=> ",
},
},
server = {
on_attach = function(_, bufnr)
-- DAP Rust keymaps
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>dr', ':RustDebuggables<CR>', { noremap = true, silent = true })
-- Keybind for RustHoverActions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', ':RustHoverActions<CR>', { noremap = true, silent = true })
end,
},
dap = {
adapter = require('rust-tools.dap').get_codelldb_adapter(
codelldb_adapter,
codelldb_lib
),
},
})
-- DAP UI integration
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
-- Define signs for breakpoints
vim.fn.sign_define('DapBreakpoint', { text = '🔴', texthl = '', linehl = '', numhl = '' })
vim.fn.sign_define('DapStopped', { text = '🟢', texthl = '', linehl = '', numhl = '' })
end,
keys = {
{ 'n', '<leader>dc', ':lua require"dap".continue()<CR>' },
{ 'n', '<leader>ds', ':lua require"dap".step_over()<CR>' },
{ 'n', '<leader>di', ':lua require"dap".step_into()<CR>' },
{ 'n', '<leader>do', ':lua require"dap".step_out()<CR>' },
{ 'n', '<leader>db', ':lua require"dap".toggle_breakpoint()<CR>' },
{ 'n', '<leader>dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>' },
{ 'n', '<leader>dr', ':lua require"dap".repl.open()<CR>' },
{ 'n', '<leader>du', ':lua require"dapui".toggle()<CR>' }
},
ft = { 'python', 'go', 'rust' }
}
}

View File

@ -0,0 +1,6 @@
return {
'sindrets/diffview.nvim',
dependencies = { 'nvim-lua/plenary.nvim' },
opts = {},
}

View File

@ -1,25 +1,41 @@
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
python = { "isort", "black" },
'stevearc/conform.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
},
event = { 'BufReadPre', 'BufNewFile' },
opts = function()
local formatters_by_ft = {
lua = { 'stylua' },
python = function(bufnr)
if require('conform').get_formatter_info('ruff_format', bufnr).available then
return { 'isort', 'ruff_format', 'ruff_fix' }
else
return { 'isort', 'black' }
end
end,
go = { 'gofumpt', 'goimports' },
}
require('conform').setup({
formatters_by_ft = formatters_by_ft,
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
})
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
require('mason-tool-installer').setup({
ensure_installed = {
'stylua',
'ruff',
'isort',
'black',
'gofumpt',
'goimports',
},
})
end, { desc = "Format file or range (in visual mode)" })
end,
}

View File

@ -2,5 +2,46 @@ return {
'tpope/vim-fugitive',
config = function()
vim.keymap.set('n', '<leader>gs', vim.cmd.Git)
local jfraeys_fugitive = vim.api.nvim_create_augroup('jfraeys_fugitive', {})
local autocmd = vim.api.nvim_create_autocmd
autocmd('BufWinEnter', {
group = jfraeys_fugitive,
pattern = '*',
callback = function()
if vim.bo.ft ~= 'fugitive' then
return
end
local bufnr = vim.api.nvim_get_current_buf()
local opts = { buffer = bufnr, remap = false }
vim.keymap.set('n', '<leader>p', function()
vim.cmd.Git 'push'
end, opts)
-- rebase always
vim.keymap.set('n', '<leader>P', function()
vim.cmd.Git { 'pull', '--rebase' }
end, opts)
-- NOTE: It allows me to easily set the branch I am pushing and any tracking
-- needed if I did not set the branch up correctly
vim.keymap.set('n', '<leader>t', ':Git push -u origin ', opts)
end,
})
vim.keymap.set('n', 'gu', '<cmd>diffget //2<CR>')
vim.keymap.set('n', 'gh', '<cmd>diffget //3<CR>')
end,
cond = function()
-- Function to check if the current directory is a Git repository
local is_git_repo = function()
local git_dir = vim.fn.finddir('.git', '.;')
return git_dir and #git_dir > 0
end
return is_git_repo()
end,
}

View File

@ -1,8 +1,9 @@
return {
-- Adds git related signs to the gutter, as well as utilities for managing changes
-- Lazy load gitsigns.nvim only if in a git repository
{
'lewis6991/gitsigns.nvim',
opts = {
-- See `:help gitsigns.txt`
-- Configuration options for gitsigns.nvim
signs = {
add = { text = '+' },
change = { text = '~' },
@ -10,23 +11,35 @@ return {
topdelete = { text = '' },
changedelete = { text = '~' },
},
-- on_attach function executed when the plugin is attached to a buffer
on_attach = function(bufnr)
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, {
buffer = bufnr, desc = 'Preview git hunk'
})
-- don't override the built-in and fugitive keymaps
local gs = package.loaded.gitsigns
-- Don't override built-in and fugitive keymaps
local gs = require('gitsigns')
vim.keymap.set({ 'n', 'v' }, ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
if vim.wo.diff then
return ']c'
end
vim.schedule(function()
gs.next_hunk()
end)
return '<Ignore>'
end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" })
end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' })
vim.keymap.set({ 'n', 'v' }, '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
if vim.wo.diff then
return '[c'
end
vim.schedule(function()
gs.prev_hunk()
end)
return '<Ignore>'
end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' })
end,
},
},
}

View File

@ -1,15 +1,40 @@
return {
"theprimeagen/harpoon",
'theprimeagen/harpoon',
branch = 'harpoon2',
dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim' },
config = function()
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
local harpoon = require 'harpoon'
vim.keymap.set("n", "<leader>a", mark.add_file, { desc = "[A]dd file harpoon" })
vim.keymap.set("n", "<C-E>", ui.toggle_quick_menu, { desc = "Go to harpoon" })
harpoon:setup()
vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end)
vim.keymap.set('n', '<leader>a', function()
harpoon:list():add()
end, { desc = 'Add file to harpoon' })
vim.keymap.set('n', '<c-e>', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end, { desc = 'Open harpoon window' })
-- vim.keymap.set("n", "<C-e>", function() toggle_telescope(harpoon.list()) end, { desc = "Open harpoon window" })
vim.keymap.set('n', '<c-h>', function()
harpoon:list():select(1)
end)
vim.keymap.set('n', '<c-t>', function()
harpoon:list():select(2)
end)
vim.keymap.set('n', '<c-n>', function()
harpoon:list():select(3)
end)
vim.keymap.set('n', '<c-s>', function()
harpoon:list():select(4)
end)
-- 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

@ -3,12 +3,14 @@ return {
'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt`
main = "ibl",
main = 'ibl',
opts = {
indent = {
--[[ highlight = highlight ]]
char = "",
smart_indent_cap = true,
char = '',
-- char = ' ',
-- char = "│",
-- smart_indent_cap = true,
},
whitespace = {
--[[ highlight = highlight, ]]
@ -17,3 +19,4 @@ return {
scope = { enabled = true },
},
}

View File

@ -1,5 +0,0 @@
-- You can add your own plugins here or in other files in this directory!
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}

View File

@ -1,38 +1,36 @@
return {
"mfussenegger/nvim-lint",
'mfussenegger/nvim-lint',
dependencies = { 'WhoIsSethDaniel/mason-tool-installer.nvim' },
event = {
"BufReadPre",
"BufNewFile",
'BufReadPre',
'BufNewFile',
},
config = function()
local lint = require("lint")
lint.linters_by_ft = {
python = { "flake8", "mypy" },
yaml = { "yamllint" },
json = { "jsonlint" }
require('lint').linters_by_ft = {
python = { 'ruff' },
go = { 'golangcilint' },
yaml = { 'yamllint' },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = lint_augroup,
callback = function()
lint.try_lint()
require('lint').try_lint()
end,
})
local mason_tool_installer = require("mason-tool-installer")
vim.keymap.set('n', '<leader>l', function()
require('lint').try_lint()
end, { desc = 'Lint the current buffer' })
mason_tool_installer.setup({
require('mason-tool-installer').setup({
ensure_installed = {
"prettier",
"stylua",
"isort",
"black",
"flake8",
"mypy",
"revive",
'ruff',
-- 'mypy',
'golangci-lint',
'yamllint',
},
})
end,

View File

@ -1,5 +1,4 @@
return {
-- LSP Configuration & Plugin
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
@ -8,88 +7,68 @@ return {
'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{
'j-hui/fidget.nvim',
tag = 'legacy',
opts = {}
opts = {},
},
-- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim',
},
config = function()
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself
-- many times.
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local on_attach = function(client, bufnr)
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
-- Key mappings for LSP features
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', function()
vim.lsp.buf.code_action(require('telescope.themes').get_dropdown {
vim.lsp.buf.code_action(require('telescope.themes').get_dropdown({
winblend = 10,
previewer = false,
})
}))
end, '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('gv', ':vsplit<CR>:lua vim.lsp.buf.declaration()<CR>', '[G]oto [V]irtual Text')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
-- vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
-- vim.lsp.buf.format()
-- end, { desc = 'Format current buffer with LSP and lint' })
-- Enable auto-formatting on save
vim.api.nvim_command([[
augroup AutoFormatOnSave
autocmd!
autocmd BufWritePre * :Format
augroup END
]])
end
-- Setup neovim lua configuration
require('neodev').setup()
local capabilities = vim.lsp.protocol.make_client_capabilities()
if pcall(require, 'cmp_nvim_lsp') then
capabilities = require('cmp_nvim_lsp').default_capabilities()
end
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = require('cmp_nvim_lsp').default_capabilities()
require('neodev').setup({
library = {
plugins = { 'nvim-dap-ui' },
types = true,
},
})
-- Servers configuration
local servers = {
clangd = {},
gopls = {
settings = {
plugins = {
revive = {},
},
gopls = {
completeUnimported = true,
usePlaceholders = true,
@ -99,89 +78,143 @@ return {
},
},
},
pylsp = {
htmx = {
filetypes = { 'html' },
},
ruff_lsp = {
filetypes = { 'python' },
},
pyright = {
filetypes = { 'python' },
settings = {
pylsp = {
plugins = {
black = {
blackArgs = {
"--line-length", "79",
"--exclude", "venv",
"--exclude", "env",
"--exclude", ".git",
"--exclude", ".hg",
},
lineLength = 79,
},
flake8 = {},
isort = {
profile = "black",
},
mypy = {
args = {},
command = "mypy",
diagnostics = true,
enabled = true,
},
pycodestyle = {
ignore = { "W391" },
maxLineLength = 79,
},
},
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
typeCheckingMode = "strict",
autoSearchPaths = false,
diagnosticMode = 'workspace',
useLibraryCodeForTypes = true,
},
pythonPath = "/usr/local/bin/python3",
typeCheckingMode = 'off',
},
},
},
},
-- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
rust_analyzer = {
cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' },
},
lua_ls = {
filetypes = { 'lua' },
settings = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
runtime = {
version = 'LuaJIT',
path = vim.split(package.path, ';'),
},
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
checkThirdParty = false,
},
telemetry = {
enable = false,
},
},
},
},
ocamllsp = {
manual_install = true,
filetypes = { 'ocaml', 'ocaml.interface', 'ocaml.cram', 'ocaml.menhir' },
settings = {
codelens = { enabled = true },
inlayHints = { enable = true },
},
},
yamlls = {
filetypes = { 'yaml' },
settings = {
yaml = {
schemas = {
['https://json.schemasstore.org/github-workflow.json'] = '/.github/workflows/*.{yml,yaml}',
},
},
},
},
taplo = {
filetypes = { 'toml' },
},
dockerls = {
filetypes = { 'Dockerfile' },
},
}
-- Setup Mason configuration
local mason = require('mason')
mason.setup {
local ensure_installed = vim.tbl_filter(function(key)
local t = servers[key]
if type(t) == 'table' then
return not t.manual_install
else
return t
end
end, vim.tbl_keys(servers))
require('mason').setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
package_installed = '',
package_pending = '',
package_uninstalled = '',
},
},
}
})
-- Ensure the servers above are installed
local mason_lspconfig = require('mason-lspconfig')
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
mason_lspconfig.setup({
ensure_installed = ensure_installed,
})
-- Add Mason handlers
mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
for name, config in pairs(servers) do
if config then
require('lspconfig')[name].setup({
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
}
settings = config.settings,
filetypes = config.filetypes,
cmd = config.cmd,
})
end
end
require('cmp')
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
text = opts.text,
numhl = '',
})
end
vim.diagnostic.config({
underline = true,
severity_sort = true,
signs = true,
update_in_insert = false,
virtual_text = {
spacing = 2,
},
float = {
source = 'if_many',
border = 'rounded',
},
})
sign({ name = 'DiagnosticSignError', text = '' })
sign({ name = 'DiagnosticSignWarn', text = '' })
sign({ name = 'DiagnosticSignHint', text = '' })
sign({ name = 'DiagnosticSignInfo', text = '»' })
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' })
vim.lsp.handlers['textDocument/signatureHelp'] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' })
end,
}
-- Load nvim-cmp after Mason to allow Mason to configure it first
require('cmp')
end
}

View File

@ -1,13 +1,33 @@
return {
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt`
opts = {
dependencies = { 'nvim-tree/nvim-web-devicons', 'tpope/vim-fugitive' },
config = function()
require('lualine').setup({
options = {
icons_enabled = false,
theme = 'onedark',
theme = 'auto',
icons_enabled = true,
component_separators = '|',
section_separators = '',
},
sections = {
lualine_a = {
{ 'buffers', show_modified_status = true, symbols = { modified = '', alternate_file = '#', directory = '' } },
},
lualine_b = {
{ 'mode', icons_enabled = true },
},
lualine_c = {
'branch',
{ 'diff', colored = false, symbols = { added = '', modified = '', removed = '' } },
},
lualine_x = {
'encoding',
{ 'fileformat', symbols = { unix = '', mac = '', dos = '' } },
'filetype',
},
},
extensions = { 'fugitive', 'nvim-tree' },
})
end,
}

8
lua/custom/plugins/marks.lua Executable file
View File

@ -0,0 +1,8 @@
return {
'chentoast/marks.nvim',
opts = {
default_mappings = true,
default_view = 'vertical',
},
}

View File

@ -2,6 +2,7 @@ return {
'tanvirtin/monokai.nvim',
priority = 1000,
config = function()
vim.cmd.colorscheme('monokai')
end,
}

19
lua/custom/plugins/neogen.lua Executable file
View File

@ -0,0 +1,19 @@
return {
'danymat/neogen',
dependencies = {
'nvim-treesitter/nvim-treesitter',
'L3MON4D3/LuaSnip',
},
keys = {
{ '<leader>nf', function() require('neogen').generate({ type = 'func' }) end, desc = 'Generate function doc' },
{ '<leader>nt', function() require('neogen').generate({ type = 'type' }) end, desc = 'Generate type doc' },
},
config = function()
require('neogen').setup({
snippet_engine = 'luasnip',
})
end,
-- Uncomment next line if you want to follow only stable versions
-- version = "*"
}

26
lua/custom/plugins/oil.lua Executable file
View File

@ -0,0 +1,26 @@
return {
'stevearc/oil.nvim',
dependencies = {
'kyazdani42/nvim-web-devicons', -- Lazy dependency for devicons
},
config = function()
require('oil').setup({
columns = {
'icon',
-- 'permissions',
},
keymaps = {
['C-h'] = false,
['M-h'] = 'actions.select_split',
},
view_options = {
show_hidden = true,
},
})
vim.keymap.set('n', '-', '<CMD>Oil<CR>', { noremap = true, silent = true, desc = 'Open parent directory' })
vim.keymap.set('n', '<leader>-', function() require('oil').toggle_float() end,
{ noremap = true, silent = true, desc = 'Toggle oil floating window' })
end,
}

View File

@ -0,0 +1,22 @@
return {
'theprimeagen/refactoring.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
},
keys = {
{ '<leader>ef', ":lua require('refactoring').refactor('Extract Function')<CR>", mode = 'x', desc = 'Extract Function' },
{ '<leader>eff', ":lua require('refactoring').refactor('Extract Function To File')<CR>", mode = 'x', desc = 'Extract Function To File' },
{ '<leader>ev', ":lua require('refactoring').refactor('Extract Variable')<CR>", mode = 'x', desc = 'Extract Variable' },
{ '<leader>eI', ":lua require('refactoring').refactor('Inline Function')<CR>", mode = 'n', desc = 'Inline Function' },
{ '<leader>ei', ":lua require('refactoring').refactor('Inline Variable')<CR>", mode = { 'n', 'x' }, desc = 'Inline Variable' },
{ '<leader>eb', ":lua require('refactoring').refactor('Extract Block')<CR>", mode = 'n', desc = 'Extract Block' },
{ '<leader>ebf', ":lua require('refactoring').refactor('Extract Block To File')<CR>", mode = 'n', desc = 'Extract Block To File' },
},
config = function()
require('refactoring').setup({
show_success_message = false,
})
end,
}

36
lua/custom/plugins/snippets.lua Executable file
View File

@ -0,0 +1,36 @@
return {
{
'L3MON4D3/LuaSnip',
-- follow latest release.
version = 'v2.*', -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = 'make install_jsregexp',
dependencies = { 'rafamadriz/friendly-snippets' },
config = function()
local ls = require('luasnip')
ls.filetype_extend('javascript', { 'jsdoc' })
ls.filetype_extend('python', { 'google' })
--- TODO: What is expand?
vim.keymap.set({ 'i' }, '<C-s>e', function()
ls.expand()
end, { silent = true })
vim.keymap.set({ 'i', 's' }, '<C-s>;', function()
ls.jump(1)
end, { silent = true })
vim.keymap.set({ 'i', 's' }, '<C-s>,', function()
ls.jump(-1)
end, { silent = true })
vim.keymap.set({ 'i', 's' }, '<C-s>', function()
if ls.choice_active() then
ls.change_choice(1)
end
end, { silent = true })
end,
},
}

View File

@ -0,0 +1,8 @@
return {
'shaunsingh/solarized.nvim',
event = "VeryLazy",
config = function()
vim.g.solarized_variant = 'light'
end,
}

View File

@ -0,0 +1,7 @@
return {
'tpope/vim-surround',
config = function()
-- You may configure any additional settings here if needed
end,
}

View File

@ -1,34 +1,44 @@
return {
"debugloop/telescope-undo.nvim",
dependencies = { -- note how they're inverted to above example
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
},
},
keys = {
{ -- lazy style key map
"<leader>u",
"<cmd>Telescope undo<cr>",
desc = "undo history",
},
},
opts = {
extensions = {
undo = {
side_by_side = true,
layout_strategy = "vertical",
layout_config = {
preview_height = 0.8,
},
},
},
},
config = function(_, opts)
-- Calling telescope's setup from multiple specs does not hurt, it will happily merge the
-- configs for us. We won't use data, as everything is in it's own namespace (telescope
-- defaults, as well as each extension).
require("telescope").setup(opts)
require("telescope").load_extension("undo")
end,
-- "debugloop/telescope-undo.nvim",
-- dependencies = { -- note how they're inverted to above example
-- {
-- "nvim-telescope/telescope.nvim",
-- dependencies = { "nvim-lua/plenary.nvim" },
-- },
-- },
-- keys = {
-- { -- lazy style key map
-- "<leader>u", "<cmd>Telescope undo<cr>", desc = "undo history",
-- },
-- },
-- opts = {
-- extensions = {
-- undo = {
-- mapping = {
-- i = {
-- ["<cr>"] = require("telescope-undo.actions").yank_additions,
-- ["<c-d>"] = require("telescope-undo.actions").yank_deletions,
-- ["<c-r>"] = require("telescope-undo.actions").restore,
-- },
-- n = {
-- ["y"] = require("telescope-undo.actions").yank_additions,
-- ["Y"] = require("telescope-undo.actions").yank_deletions,
-- ["u"] = require("telescope-undo.actions").restore,
-- },
-- },
-- side_by_side = true,
-- layout_strategy = "vertical",
-- layout_config = {
-- preview_height = 0.8,
-- },
-- },
-- },
-- },
-- config = function(_, opts)
-- -- Calling telescope's setup from multiple specs does not hurt, it will happily merge the
-- -- configs for us. We won't use data, as everything is in it's own namespace (telescope
-- -- defaults, as well as each extension).
-- require("telescope").setup(opts)
-- require("telescope").load_extension("undo")
-- end,
}

View File

@ -1,6 +1,7 @@
return {
-- Fuzzy Finder (files, lsp, etc)
'nvim-telescope/telescope.nvim',
event = "VimEnter",
branch = '0.1.x',
dependencies = {
'nvim-lua/plenary.nvim',
@ -13,13 +14,14 @@ return {
-- NOTE: If you are having trouble with this installation,
-- refer to the README for telescope-fzf-native for more instructions.
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
config = function()
require('telescope').load_extension('fzf')
end,
},
'nvim-tree/nvim-web-devicons',
},
config = function()
-- Configure Telescope
require('telescope').setup({
defaults = {
mappings = {
@ -30,30 +32,19 @@ return {
},
},
})
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
-- Telescope live_grep in git root
-- Function to find the git root directory based on the current buffer's path
local function find_git_root()
-- Use the current buffer's path as the starting point for the git search
local current_file = vim.api.nvim_buf_get_name(0)
local current_dir
local cwd = vim.fn.getcwd()
-- If the buffer is not associated with a file, return nil
if current_file == "" then
current_dir = cwd
else
-- Extract the directory from the current file's path
current_dir = vim.fn.fnamemodify(current_file, ":h")
end
local current_dir = current_file == '' and vim.fn.getcwd() or vim.fn.fnamemodify(current_file, ':h')
-- Find the Git root directory from the current file's path
local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")
[1]
local git_root =
vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1]
if vim.v.shell_error ~= 0 then
print("Not a git repository. Searching on current working directory")
return cwd
print('Not a git repository. Searching on the current working directory.')
return vim.fn.getcwd()
end
return git_root
end
@ -68,8 +59,8 @@ return {
end
end
-- Define a user command for live_grep_git_root
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
-- require("telescope").extensions.undo.undo()
end,
}

View File

@ -3,23 +3,22 @@ return {
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
'https://github.com/apple/pkl-neovim.git',
'windwp/nvim-ts-autotag',
},
build = ':TSUpdate',
-- setup autotag with default options
opts = {
enable = true,
},
config = function()
-- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'lua', 'python', 'go', 'vimdoc', 'vim' },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
highlight = { enable = true },
-- Lazy loading of treesitter
local ts = require('nvim-treesitter.configs')
ts.setup({
ensure_installed = {
'c', 'cpp', 'lua', 'python', 'go', 'rust', 'vimdoc', 'vim'
},
ignore_install = { '' },
highlight = {
enable = true,
additional_vim_regex_highlighting = { 'markdown' },
},
indent = { enable = true },
incremental_selection = {
enable = true,
@ -33,9 +32,8 @@ return {
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
@ -46,7 +44,7 @@ return {
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
set_jumps = true,
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
@ -74,6 +72,17 @@ return {
},
},
},
})
-- Autotag setup
require('nvim-ts-autotag').setup({
enable = true,
})
end,
opts = {
autotag = {
enable = true,
},
},
}
end
}

15
lua/custom/plugins/trouble.lua Executable file
View File

@ -0,0 +1,15 @@
return {
'folke/trouble.nvim',
cmd = "Trouble",
opts = {
auto_open = false,
auto_close = true,
auto_preview = true,
auto_fold = true,
use_diagnostic_signs = true,
},
keys = {
{ "<leader>tt", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)" },
},
}

View File

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

View File

@ -1,45 +1,40 @@
return {
"linux-cultist/venv-selector.nvim",
dependencies = { "neovim/nvim-lspconfig", "nvim-telescope/telescope.nvim" },
event = "VeryLazy", -- Optional: needed only if you want to type `:VenvSelect` without a keymapping
keys = {
{
"<leader>vs", "<cmd>:VenvSelect<cr>",
-- Key mapping for directly retrieving from cache. You may set an autocmd if you prefer the hands-free approach.
"<leader>vc", "<cmd>:VenvSelectCached<cr>"
}
'linux-cultist/venv-selector.nvim',
dependencies = {
'neovim/nvim-lspconfig',
{ 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } },
},
config = function()
-- Function to find the nearest venv path in parent directories.
local function find_nearest_venv(starting_path)
local current_path = starting_path
while current_path do
local venv_path = current_path .. '/venv/bin/python'
if vim.fn.filereadable(venv_path) == 1 then
return venv_path
end
local parent_path = vim.fn.fnamemodify(current_path, ':h')
if parent_path == current_path then
break
end
current_path = parent_path
end
return nil
end
ft = 'python', -- Load only for Python files
branch = 'regexp', -- This is the regexp branch, use this for the new version
opts = {
settings = {
options = {
-- If you put the callback here as a global option, its used for all searches (including the default ones by the plugin)
on_telescope_result_callback = function(filename)
return filename:gsub('/bin/python', '')
end,
},
debug = true,
-- Get the path of the current file.
local current_file = vim.fn.expand('%:p')
-- Get the venv path for the current project directory.
local venv_path = find_nearest_venv(current_file)
if venv_path then
-- Activate the venv and use its Python interpreter.
vim.g.venv_selector_auto_activate = 1
vim.g.python3_host_prog = venv_path
else
-- Fallback to a system-wide Python interpreter.
vim.g.python3_host_prog = '/usr/bin/python3'
end
end
search = {
my_venvs = {
command = 'fd -H -I python$ ~/Documents/Projects/',
on_telescope_result_callback = function(filename)
return filename:gsub('/bin/python', '')
end,
},
my_conda_envs = {
command = 'fd -t l python$ /usr/local/Caskroom/miniforge/base/envs/',
on_telescope_result_callback = function(filename)
return filename:gsub('/bin/python', '')
end,
},
},
},
},
keys = {
{ ',v', '<cmd>VenvSelect<cr>' },
},
},
}

View File

@ -1,13 +1,18 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
'folke/which-key.nvim',
event = 'VimEnter',
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
plugins = {
marks = true,
registers = true,
spelling = {
enabled = true,
suggestions = 20,
},
},
windows = {
border = 'single',
},
},
}

View File

@ -0,0 +1,26 @@
local ls = require('luasnip')
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node
local fmt = require('luasnip.extras.fmt').fmt
ls.add_snippets('go', {
s('ee', {
t({ 'panic(' }),
i(1, 'err'),
t({ ')' }),
}),
s(
'ei',
fmt(
[[
if err != nil {{
panic({})
}}
]],
{ i(1, 'err') }
)
),
})

View File

@ -0,0 +1,20 @@
local ls = require 'luasnip'
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node
ls.add_snippets('lua', {
s('lr', {
t 'local ',
i(1, 'module'),
t ' = require("',
i(2, 'module'),
t '")',
}),
s('pr', {
t 'print(',
i(1, 'text'),
t ')',
}),
})

View File

@ -0,0 +1,15 @@
local ls = require('luasnip')
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node
ls.add_snippets('python', {
s('log', {
t({ 'LOG.' }),
i(1, 'level'),
t({ '(' }),
i(2, 'message'),
t({ ')' }),
}),
})