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" line_endings = "Unix"
indent_type = "Spaces" indent_type = "Spaces"
indent_width = 2 indent_width = 2
call_parentheses = "Always"
quote_style = "AutoPreferSingle" 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 -- Install package manager
-- https://github.com/folke/lazy.nvim -- 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 if not vim.loop.fs_stat(lazypath) then
vim.fn.system { vim.fn.system({
'git', 'git',
'clone', 'clone',
'--filter=blob:none', '--filter=blob:none',
'https://github.com/folke/lazy.nvim.git', 'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release '--branch=stable', -- latest stable release
lazypath, lazypath,
} })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
local opts = { vim.g.mapleader = ' '
git = { log = { '--since=3 days ago' } }, vim.g.maplocalleader = ' '
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)
require('config.lazy')
require('config.autocmds')
require('config.options') require('config.options')
require('config.mappings') require('config.mappings')
require('config.utils') require('config.utils')
require('config.themes') 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 -- Keymaps for better default experience
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) 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 -- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
expr = true, silent = true vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { 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
})
-- Move lines -- Move lines
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { silent = true }) 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('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") -- Miscellaneous Navigation Keymaps
vim.keymap.set('n', '<C-d>', "<C-d>zz", { desc = "Half Page Jumping Up" }) vim.keymap.set('n', 'J', 'mzj`z')
vim.keymap.set('n', '<C-u>', "<C-u>zz", { desc = "Half Page Jumping Down" }) 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
vim.keymap.set('n', 'n', 'nzzzv', { silent = true }) vim.keymap.set('n', 'n', 'nzzzv', { silent = true })
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.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 -- Buffer Navigation Keymaps
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz") vim.keymap.set('n', '<leader>bn', '<cmd>bnext<CR>zz', { desc = 'Quick Nav Buf Next' })
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz") vim.keymap.set('n', '<leader>bp', '<cmd>bprev<CR>zz', { desc = 'Quick Nav Buf Prev' })
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Quick Fix Nav Up" }) vim.keymap.set('n', '<leader>bd', '<cmd>bdelete<CR>', { desc = 'Quick Nav Buf Delete' })
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Quick Fix Nav Down" }) 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 -- Editing Keymaps
vim.keymap.set({ 'n', 'v' }, '<leader>y', "\"+y", { desc = "Copy to + register" }) vim.keymap.set('x', '<leader>p', [["_dP"]], { desc = 'Paste without register' })
vim.keymap.set('n', '<leader>Y', "\"+Y") 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 -- Open vertical split pane
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 })
-- [ 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` -- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) 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><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function() 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.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { require('telescope.themes').get_dropdown({ winblend = 10, previewer = false })
winblend = 10, )
previewer = false,
})
-- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes'))
end, { desc = '[/] Fuzzily search in current buffer' }) 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>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>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 -- 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_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', ']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>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 -- Refactoring Keymaps
vim.keymap.set('n', '<leader>q', function() -- vim.keymap.set({ "x" }, "<leader>re", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]],
vim.diagnostic.setloclist() -- { noremap = true, silent = true, expr = false, desc = "Extract Function" })
vim.cmd('lopen') -- vim.keymap.set({ "x" }, "<leader>rf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]],
end, { -- { noremap = true, silent = true, expr = false, desc = "Extract Function To File" })
noremap = true, -- vim.keymap.set({ "x" }, "<leader>rv", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Variable')<CR>]],
silent = true, -- { noremap = true, silent = true, expr = false, desc = "Extract Variable" })
expr = false, -- vim.keymap.set({ "n" }, "<leader>rI", [[<Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]],
desc = 'Open the diagnostics location list' -- { 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 = { local opts = {
-- Change cursor in insert mode -- 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 -- Make line numbers default
relativenumber = true, relativenumber = true,
--Enable noshowmode
showmode = false,
-- Enable break indent -- Enable break indent
breakindent = true, breakindent = true,
@ -16,7 +25,6 @@ local opts = {
softtabstop = 4, softtabstop = 4,
shiftwidth = 4, shiftwidth = 4,
expandtab = true, expandtab = true,
smartindent = true,
-- Disable line wrap -- Disable line wrap
wrap = false, wrap = false,
@ -24,7 +32,7 @@ local opts = {
-- Save undo history -- Save undo history
swapfile = false, swapfile = false,
backup = false, backup = false,
undodir = vim.fn.stdpath("data") .. "/site/undodir", undodir = vim.fn.stdpath('data') .. '/site/undodir',
undofile = true, undofile = true,
-- Searching Configuration -- Searching Configuration
@ -45,7 +53,6 @@ local opts = {
-- NOTE: You should make sure your terminal supports this -- NOTE: You should make sure your terminal supports this
termguicolors = true, termguicolors = true,
scrolloff = 10, scrolloff = 10,
colorcolumn = "80",
pyxversion = 3, pyxversion = 3,
} }
@ -64,31 +71,31 @@ end
-- Disable built-in plugins -- Disable built-in plugins
local disabled_built_ins = { local disabled_built_ins = {
"2html_plugin", '2html_plugin',
"getscript", 'getscript',
"getscriptPlugin", 'getscriptPlugin',
"gzip", 'gzip',
"logipat", 'logipat',
"matchit", 'matchit',
-- "netrw", -- "netrw",
"netrwFileHandlers", 'netrwFileHandlers',
"loaded_remote_plugins", 'loaded_remote_plugins',
"loaded_tutor_mode_plugin", 'loaded_tutor_mode_plugin',
-- "netrwPlugin", -- "netrwPlugin",
-- "netrwSettings", -- "netrwSettings",
"rrhelper", 'rrhelper',
"spellfile_plugin", 'spellfile_plugin',
"tar", 'tar',
"tarPlugin", 'tarPlugin',
"vimball", 'vimball',
"vimballPlugin", 'vimballPlugin',
"zip", 'zip',
"zipPlugin", 'zipPlugin',
"matchparen", 'matchparen',
} }
for _, plugin in pairs(disabled_built_ins) do for _, plugin in pairs(disabled_built_ins) do
g["loaded_" .. plugin] = 1 g['loaded_' .. plugin] = 1
end end
-- Improve Neovim startup -- Improve Neovim startup
@ -107,13 +114,14 @@ for k, v in pairs(global_let_opts) do
g[k] = v g[k] = v
end end
opt.formatoptions = "l" opt.formatoptions = 'l'
opt.formatoptions = opt.formatoptions opt.formatoptions = opt.formatoptions
- "a" -- Auto formatting is BAD. - 'a' -- Auto formatting is BAD.
- "t" -- Don't auto format my code. I got linters for that. - 't' -- Don't auto format my code. I got linters for that.
+ "c" -- In general, I like it when comments respect textwidth + 'c' -- In general, I like it when comments respect textwidth
- "o" -- O and o, don't continue comments - 'o' -- O and o, don't continue comments
+ "r" -- But do continue when pressing enter. + 'r' -- But do continue when pressing enter.
+ "n" -- Indent past the formatlistpat, not underneath it. + 'n' -- Indent past the formatlistpat, not underneath it.
+ "j" -- Auto-remove comments if possible. + 'j' -- Auto-remove comments if possible.
- "2" -- I'm not in gradeschool anymore - '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 { return {
"windwp/nvim-autopairs", 'windwp/nvim-autopairs',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' }, dependencies = { 'hrsh7th/nvim-cmp' },
event = 'InsertEnter',
config = function() config = function()
require("nvim-autopairs").setup {} require('nvim-autopairs').setup({})
-- If you want to automatically add `(` after selecting a function or method -- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp') local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp') local cmp = require('cmp')
cmp.event:on( cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
'confirm_done',
cmp_autopairs.on_confirm_done()
)
end, end,
} }

View File

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

View File

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

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

@ -1,3 +1,20 @@
return { 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 { return {
"stevearc/conform.nvim", 'stevearc/conform.nvim',
event = { "BufReadPre", "BufNewFile" }, dependencies = {
config = function() 'nvim-lua/plenary.nvim',
local conform = require("conform") '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' },
}
conform.setup({ require('conform').setup({
formatters_by_ft = { formatters_by_ft = formatters_by_ft,
python = { "isort", "black" },
},
format_on_save = { format_on_save = {
lsp_fallback = true, lsp_fallback = true,
async = false,
timeout_ms = 500, timeout_ms = 500,
}, },
}) })
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
conform.format({ require('mason-tool-installer').setup({
lsp_fallback = true, ensure_installed = {
async = false, 'stylua',
timeout_ms = 500, 'ruff',
}) 'isort',
end, { desc = "Format file or range (in visual mode)" }) 'black',
'gofumpt',
'goimports',
},
})
end, end,
} }

View File

@ -2,5 +2,46 @@ return {
'tpope/vim-fugitive', 'tpope/vim-fugitive',
config = function() config = function()
vim.keymap.set('n', '<leader>gs', vim.cmd.Git) vim.keymap.set('n', '<leader>gs', vim.cmd.Git)
end
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,32 +1,45 @@
return { 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 = { 'lewis6991/gitsigns.nvim',
-- See `:help gitsigns.txt` opts = {
signs = { -- Configuration options for gitsigns.nvim
add = { text = '+' }, signs = {
change = { text = '~' }, add = { text = '+' },
delete = { text = '_' }, change = { text = '~' },
topdelete = { text = '' }, delete = { text = '_' },
changedelete = { text = '~' }, topdelete = { text = '' },
}, changedelete = { text = '~' },
on_attach = function(bufnr) },
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { -- on_attach function executed when the plugin is attached to a buffer
buffer = bufnr, desc = 'Preview git hunk' 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 -- Don't override built-in and fugitive keymaps
local gs = package.loaded.gitsigns local gs = require('gitsigns')
vim.keymap.set({ 'n', 'v' }, ']c', function() vim.keymap.set({ 'n', 'v' }, ']c', function()
if vim.wo.diff then return ']c' end if vim.wo.diff then
vim.schedule(function() gs.next_hunk() end) return ']c'
return '<Ignore>' end
end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) vim.schedule(function()
vim.keymap.set({ 'n', 'v' }, '[c', function() gs.next_hunk()
if vim.wo.diff then return '[c' end end)
vim.schedule(function() gs.prev_hunk() end) return '<Ignore>'
return '<Ignore>' end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' })
end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
end, vim.keymap.set({ 'n', 'v' }, '[c', function()
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,
},
}, },
} }

View File

@ -1,15 +1,40 @@
return { return {
"theprimeagen/harpoon", 'theprimeagen/harpoon',
config = function() branch = 'harpoon2',
local mark = require("harpoon.mark") dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim' },
local ui = require("harpoon.ui") config = function()
local harpoon = require 'harpoon'
vim.keymap.set("n", "<leader>a", mark.add_file, { desc = "[A]dd file harpoon" }) harpoon:setup()
vim.keymap.set("n", "<C-E>", ui.toggle_quick_menu, { desc = "Go to harpoon" })
vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end) vim.keymap.set('n', '<leader>a', function()
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end) harpoon:list():add()
vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end) end, { desc = 'Add file to harpoon' })
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end) vim.keymap.set('n', '<c-e>', function()
end, 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', 'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim` -- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt` -- See `:help indent_blankline.txt`
main = "ibl", main = 'ibl',
opts = { opts = {
indent = { indent = {
--[[ highlight = highlight ]] --[[ highlight = highlight ]]
char = "", char = '',
smart_indent_cap = true, -- char = ' ',
-- char = "│",
-- smart_indent_cap = true,
}, },
whitespace = { whitespace = {
--[[ highlight = highlight, ]] --[[ highlight = highlight, ]]
@ -17,3 +19,4 @@ return {
scope = { enabled = true }, 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 { return {
"mfussenegger/nvim-lint", 'mfussenegger/nvim-lint',
dependencies = { 'WhoIsSethDaniel/mason-tool-installer.nvim' },
event = { event = {
"BufReadPre", 'BufReadPre',
"BufNewFile", 'BufNewFile',
}, },
config = function() config = function()
local lint = require("lint") require('lint').linters_by_ft = {
python = { 'ruff' },
lint.linters_by_ft = { go = { 'golangcilint' },
python = { "flake8", "mypy" }, yaml = { 'yamllint' },
yaml = { "yamllint" },
json = { "jsonlint" }
} }
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, group = lint_augroup,
callback = function() callback = function()
lint.try_lint() require('lint').try_lint()
end, 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 = { ensure_installed = {
"prettier", 'ruff',
"stylua", -- 'mypy',
"isort", 'golangci-lint',
"black", 'yamllint',
"flake8",
"mypy",
"revive",
}, },
}) })
end, end,

View File

@ -1,5 +1,4 @@
return { return {
-- LSP Configuration & Plugin
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
-- Automatically install LSPs to stdpath for neovim -- Automatically install LSPs to stdpath for neovim
@ -8,88 +7,68 @@ return {
'WhoIsSethDaniel/mason-tool-installer.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP -- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ {
'j-hui/fidget.nvim', 'j-hui/fidget.nvim',
tag = 'legacy', tag = 'legacy',
opts = {} opts = {},
}, },
-- Additional lua configuration, makes nvim stuff amazing! -- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim', 'folke/neodev.nvim',
}, },
config = function() config = function()
-- This function gets run when an LSP connects to a particular buffer. local on_attach = function(client, bufnr)
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 nmap = function(keys, func, desc) local nmap = function(keys, func, desc)
if desc then if desc then
desc = 'LSP: ' .. desc desc = 'LSP: ' .. desc
end end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end end
-- Key mappings for LSP features
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', function() 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, winblend = 10,
previewer = false, previewer = false,
}) }))
end, '[C]ode [A]ction') 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('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') 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>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') 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('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature 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('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>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>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function() nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist 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 end
-- Setup neovim lua configuration local capabilities = vim.lsp.protocol.make_client_capabilities()
require('neodev').setup() 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 require('neodev').setup({
local capabilities = require('cmp_nvim_lsp').default_capabilities() library = {
plugins = { 'nvim-dap-ui' },
types = true,
},
})
-- Servers configuration
local servers = { local servers = {
clangd = {}, clangd = {},
gopls = { gopls = {
settings = { settings = {
plugins = {
revive = {},
},
gopls = { gopls = {
completeUnimported = true, completeUnimported = true,
usePlaceholders = true, usePlaceholders = true,
@ -99,89 +78,143 @@ return {
}, },
}, },
}, },
pylsp = { htmx = {
filetypes = { 'html' },
},
ruff_lsp = {
filetypes = { 'python' },
},
pyright = {
filetypes = { 'python' },
settings = { settings = {
pylsp = { python = {
plugins = { analysis = {
black = { autoSearchPaths = false,
blackArgs = { diagnosticMode = 'workspace',
"--line-length", "79", useLibraryCodeForTypes = true,
"--exclude", "venv", typeCheckingMode = 'off',
"--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",
useLibraryCodeForTypes = true,
},
pythonPath = "/usr/local/bin/python3",
}, },
}, },
}, },
}, },
-- rust_analyzer = {}, rust_analyzer = {
-- tsserver = {}, cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' },
-- html = { filetypes = { 'html', 'twig', 'hbs'} }, },
lua_ls = { lua_ls = {
Lua = { filetypes = { 'lua' },
workspace = { checkThirdParty = false }, settings = {
telemetry = { enable = false }, Lua = {
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 ensure_installed = vim.tbl_filter(function(key)
local mason = require('mason') local t = servers[key]
mason.setup { if type(t) == 'table' then
return not t.manual_install
else
return t
end
end, vim.tbl_keys(servers))
require('mason').setup({
ui = { ui = {
icons = { icons = {
package_installed = "", package_installed = '',
package_pending = "", package_pending = '',
package_uninstalled = "", package_uninstalled = '',
}, },
}, },
} })
-- Ensure the servers above are installed
local mason_lspconfig = require('mason-lspconfig') local mason_lspconfig = require('mason-lspconfig')
mason_lspconfig.setup { mason_lspconfig.setup({
ensure_installed = vim.tbl_keys(servers), ensure_installed = ensure_installed,
} })
-- Add Mason handlers for name, config in pairs(servers) do
mason_lspconfig.setup_handlers { if config then
function(server_name) require('lspconfig')[name].setup({
require('lspconfig')[server_name].setup {
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
settings = servers[server_name], settings = config.settings,
filetypes = (servers[server_name] or {}).filetypes, filetypes = config.filetypes,
} cmd = config.cmd,
})
end end
} end
-- Load nvim-cmp after Mason to allow Mason to configure it first
require('cmp') require('cmp')
end
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,
} }

View File

@ -1,13 +1,33 @@
return { return {
-- Set lualine as statusline
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt` dependencies = { 'nvim-tree/nvim-web-devicons', 'tpope/vim-fugitive' },
opts = { config = function()
options = { require('lualine').setup({
icons_enabled = false, options = {
theme = 'onedark', theme = 'auto',
component_separators = '|', icons_enabled = true,
section_separators = '', 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', 'tanvirtin/monokai.nvim',
priority = 1000, priority = 1000,
config = function() config = function()
vim.cmd.colorscheme('monokai')
end, 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 { return {
"debugloop/telescope-undo.nvim", -- "debugloop/telescope-undo.nvim",
dependencies = { -- note how they're inverted to above example -- dependencies = { -- note how they're inverted to above example
{ -- {
"nvim-telescope/telescope.nvim", -- "nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" }, -- dependencies = { "nvim-lua/plenary.nvim" },
}, -- },
}, -- },
keys = { -- keys = {
{ -- lazy style key map -- { -- lazy style key map
"<leader>u", -- "<leader>u", "<cmd>Telescope undo<cr>", desc = "undo history",
"<cmd>Telescope undo<cr>", -- },
desc = "undo history", -- },
}, -- opts = {
}, -- extensions = {
opts = { -- undo = {
extensions = { -- mapping = {
undo = { -- i = {
side_by_side = true, -- ["<cr>"] = require("telescope-undo.actions").yank_additions,
layout_strategy = "vertical", -- ["<c-d>"] = require("telescope-undo.actions").yank_deletions,
layout_config = { -- ["<c-r>"] = require("telescope-undo.actions").restore,
preview_height = 0.8, -- },
}, -- n = {
}, -- ["y"] = require("telescope-undo.actions").yank_additions,
}, -- ["Y"] = require("telescope-undo.actions").yank_deletions,
}, -- ["u"] = require("telescope-undo.actions").restore,
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 -- side_by_side = true,
-- defaults, as well as each extension). -- layout_strategy = "vertical",
require("telescope").setup(opts) -- layout_config = {
require("telescope").load_extension("undo") -- preview_height = 0.8,
end, -- },
-- },
-- },
-- },
-- 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 { return {
-- Fuzzy Finder (files, lsp, etc) -- Fuzzy Finder (files, lsp, etc)
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
event = "VimEnter",
branch = '0.1.x', branch = '0.1.x',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
@ -13,13 +14,14 @@ return {
-- NOTE: If you are having trouble with this installation, -- NOTE: If you are having trouble with this installation,
-- refer to the README for telescope-fzf-native for more instructions. -- refer to the README for telescope-fzf-native for more instructions.
build = 'make', build = 'make',
cond = function() config = function()
return vim.fn.executable 'make' == 1 require('telescope').load_extension('fzf')
end, end,
}, },
'nvim-tree/nvim-web-devicons', 'nvim-tree/nvim-web-devicons',
}, },
config = function() config = function()
-- Configure Telescope
require('telescope').setup({ require('telescope').setup({
defaults = { defaults = {
mappings = { mappings = {
@ -30,30 +32,19 @@ return {
}, },
}, },
}) })
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
-- Telescope live_grep in git root -- 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() local function find_git_root()
-- Use the current buffer's path as the starting point for the git search -- 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_file = vim.api.nvim_buf_get_name(0)
local current_dir local current_dir = current_file == '' and vim.fn.getcwd() or vim.fn.fnamemodify(current_file, ':h')
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
-- Find the Git root directory from the current file's path -- 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") local git_root =
[1] vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1]
if vim.v.shell_error ~= 0 then if vim.v.shell_error ~= 0 then
print("Not a git repository. Searching on current working directory") print('Not a git repository. Searching on the current working directory.')
return cwd return vim.fn.getcwd()
end end
return git_root return git_root
end end
@ -68,8 +59,8 @@ return {
end end
end end
-- Define a user command for live_grep_git_root
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
-- require("telescope").extensions.undo.undo()
end, end,
} }

View File

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

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 { return {
-- 'mbbill/undotree', 'mbbill/undotree',
-- config = function() config = function()
-- vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' }) vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' })
-- end end,
} }

View File

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

View File

@ -1,13 +1,18 @@
return { return {
"folke/which-key.nvim", 'folke/which-key.nvim',
event = "VeryLazy", event = 'VimEnter',
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = { opts = {
-- your configuration comes here plugins = {
-- or leave it empty to use the default settings marks = true,
-- refer to the configuration section below 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({ ')' }),
}),
})