diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/.idea/.gitignore
@@ -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
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..b4cde646
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..105ce2da
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..a6218fed
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.stylua.toml b/.stylua.toml
index 139e9397..b14df1da 100755
--- a/.stylua.toml
+++ b/.stylua.toml
@@ -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
+
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua
new file mode 100644
index 00000000..4f922be7
--- /dev/null
+++ b/after/ftplugin/c.lua
@@ -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')
diff --git a/after/ftplugin/crontab.lua b/after/ftplugin/crontab.lua
new file mode 100644
index 00000000..d152a34b
--- /dev/null
+++ b/after/ftplugin/crontab.lua
@@ -0,0 +1 @@
+vim.opt_local.fixeol = false
diff --git a/after/ftplugin/dockerfile.lua b/after/ftplugin/dockerfile.lua
new file mode 100644
index 00000000..7307b615
--- /dev/null
+++ b/after/ftplugin/dockerfile.lua
@@ -0,0 +1,2 @@
+vim.opt_local.expandtab = true
+vim.opt_local.shiftwidth = 2
diff --git a/after/ftplugin/go.lua b/after/ftplugin/go.lua
new file mode 100644
index 00000000..cd6a645d
--- /dev/null
+++ b/after/ftplugin/go.lua
@@ -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', 'td', function()
+ require('dap-go').debug_test()
+end, { buffer = 0 }) -- Set buffer-local key mapping
+
diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua
new file mode 100644
index 00000000..b3842696
--- /dev/null
+++ b/after/ftplugin/lua.lua
@@ -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'
+
diff --git a/after/ftplugin/make.lua b/after/ftplugin/make.lua
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/after/ftplugin/make.lua
@@ -0,0 +1 @@
+
diff --git a/after/ftplugin/ocaml.lua b/after/ftplugin/ocaml.lua
new file mode 100644
index 00000000..bc67025c
--- /dev/null
+++ b/after/ftplugin/ocaml.lua
@@ -0,0 +1,5 @@
+vim.opt.shiftwidth = 2
+
+-- vim.keymap.set('n', 'cp', require('ocaml.mappings').dune_promote_file, { buffer = 0 })
+--
+
diff --git a/after/ftplugin/python.lua b/after/ftplugin/python.lua
new file mode 100644
index 00000000..e0cca3b5
--- /dev/null
+++ b/after/ftplugin/python.lua
@@ -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'
diff --git a/after/ftplugin/rust.lua b/after/ftplugin/rust.lua
new file mode 100644
index 00000000..22b5398b
--- /dev/null
+++ b/after/ftplugin/rust.lua
@@ -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', 'r', 'Cargo run', { desc = 'Run the current Rust project', noremap = true })
+vim.keymap.set('n', 'c', 'Cargo check', { desc = 'Check the current Rust project', noremap = true })
+
diff --git a/after/ftplugin/sh.lua b/after/ftplugin/sh.lua
new file mode 100644
index 00000000..78d5d27a
--- /dev/null
+++ b/after/ftplugin/sh.lua
@@ -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
diff --git a/after/ftplugin/sql.lua b/after/ftplugin/sql.lua
new file mode 100644
index 00000000..ad59a736
--- /dev/null
+++ b/after/ftplugin/sql.lua
@@ -0,0 +1 @@
+vim.opt_local.commentstring = '-- %s'
diff --git a/after/ftplugin/yaml.lua b/after/ftplugin/yaml.lua
new file mode 100644
index 00000000..e69de29b
diff --git a/doc/kickstart.txt b/doc/kickstart.txt
deleted file mode 100755
index cb87ac3f..00000000
--- a/doc/kickstart.txt
+++ /dev/null
@@ -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:
diff --git a/doc/tags b/doc/tags
deleted file mode 100755
index 687ae772..00000000
--- a/doc/tags
+++ /dev/null
@@ -1,3 +0,0 @@
-kickstart-is kickstart.txt /*kickstart-is*
-kickstart-is-not kickstart.txt /*kickstart-is-not*
-kickstart.nvim kickstart.txt /*kickstart.nvim*
diff --git a/init.lua b/init.lua
index 4efc851a..f2708180 100755
--- a/init.lua
+++ b/init.lua
@@ -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')
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua
new file mode 100755
index 00000000..45b5288c
--- /dev/null
+++ b/lua/config/autocmds.lua
@@ -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
+]])
+
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua
new file mode 100755
index 00000000..ab6217a9
--- /dev/null
+++ b/lua/config/lazy.lua
@@ -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)
+
diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua
index ce8f7be7..63450a3f 100755
--- a/lua/config/mappings.lua
+++ b/lua/config/mappings.lua
@@ -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' }, '', '', { silent = true })
-vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
+-- vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
+vim.keymap.set('n', '', '', { 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 '>+1gv=gv", { silent = true })
vim.keymap.set('v', 'K', ":m '<-2gv=gv", { silent = true })
+vim.keymap.set('n', '>', '>gv', { silent = true })
+vim.keymap.set('n', '<', '', "zz", { desc = "Half Page Jumping Up" })
-vim.keymap.set('n', '', "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', '', 'zz', { desc = 'Half Page Jumping Up' })
+vim.keymap.set('n', '', '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', '', { noremap = true, silent = true })
+vim.keymap.set('n', '', 'cnextzz')
+vim.keymap.set('n', '', 'cprevzz')
+vim.keymap.set('n', 'k', 'lnextzz', { desc = 'Quick Fix Nav Up' })
+vim.keymap.set('n', 'j', 'lprevzz', { desc = 'Quick Fix Nav Down' })
--- Quick fix navigation
-vim.keymap.set("n", "", "cnextzz")
-vim.keymap.set("n", "", "cprevzz")
-vim.keymap.set("n", "k", "lnextzz", { desc = "Quick Fix Nav Up" })
-vim.keymap.set("n", "j", "lprevzz", { desc = "Quick Fix Nav Down" })
+-- Buffer Navigation Keymaps
+vim.keymap.set('n', 'bn', 'bnextzz', { desc = 'Quick Nav Buf Next' })
+vim.keymap.set('n', 'bp', 'bprevzz', { desc = 'Quick Nav Buf Prev' })
+vim.keymap.set('n', 'bd', 'bdelete', { desc = 'Quick Nav Buf Delete' })
+vim.keymap.set('n', 'bs', 'split', { desc = 'Openn Buf Horizontal Split' })
+vim.keymap.set('n', 'bv', 'vsp', { desc = 'Open Buf Vertical Split' })
+vim.keymap.set('n', 'bt', 'terminal')
--- Copy from plus register
-vim.keymap.set({ 'n', 'v' }, 'y', "\"+y", { desc = "Copy to + register" })
-vim.keymap.set('n', 'Y', "\"+Y")
+-- Editing Keymaps
+vim.keymap.set('x', 'p', [["_dP"]], { desc = 'Paste without register' })
+vim.keymap.set({ 'n', 'v' }, 'd', [["_d"]], { desc = 'Delete without register' })
+vim.keymap.set({ 'n', 'v' }, 'y', '"+y', { desc = 'Copy to + register' })
+vim.keymap.set('n', 'Y', '"+Y')
+-- replace current word in current scope
+vim.keymap.set(
+ 'n',
+ 'r',
+ ':%s/\\<\\>//gI',
+ { desc = '[R]eplace Current Word in Current Scope' }
+)
+-- replace current word in file scope
+vim.keymap.set(
+ 'n',
+ 'R',
+ ':%s/\\<\\>//gI',
+ { desc = '[R]eplace Current Word in File Scope' }
+)
--- Replace current word
-vim.keymap.set("n", "r", [[:%s/\<\>//gI]],
- { desc = "[R]eplace Current Word" })
-vim.keymap.set("n", "x", "!chmod +x %", { desc = "Set Current File to Executable", silent = true })
+-- Open vertical split pane
--- [ telescope keymaps]
+-- File Management Keymaps
+vim.keymap.set('n', '', 'silent !tmux neww $HOME/.local/bin/tmux_sessionizer', { desc = 'Open Session' })
+vim.keymap.set('n', 'x', '!chmod +x %', { desc = 'Set Current File to Executable', silent = true })
+
+-- Telescope Keymaps
-- See `:help telescope.builtin`
vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '/', 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', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
+vim.keymap.set('n', 'gb', require('telescope.builtin').git_branches, { desc = 'Search [G]it [B]ranches' })
+vim.keymap.set('n', 'gc', require('telescope.builtin').git_commits, { desc = 'Search [G]it [C]ommits' })
vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
-vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
-vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
-vim.keymap.set('n', 'sp', function()
- require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") })
-end, { desc = '[S]search [P]roject' })
-vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
-vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
-vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' })
--- [ tree-sitter keymaps ]
+vim.keymap.set({ 'n', 'v' }, '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' }, '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', 'sp', function()
+ require('telescope.builtin').grep_string({ search = vim.fn.input('Grep Search > ') })
+end, { desc = '[S]search [P]roject' })
+vim.keymap.set('n', 'sG', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
+vim.keymap.set('n', 'sg', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' })
+vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
+vim.keymap.set('n', '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', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
+-- vim.keymap.set('n', 'vd', function()
+-- vim.diagnostic.setloclist()
+-- vim.cmd('lopen')
+-- end, { desc = 'Open the diagnostics location list' })
--- Open the diagnostics location list
-vim.keymap.set('n', '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" }, "re", [[lua require('refactoring').refactor('Extract Function')]],
+-- { noremap = true, silent = true, expr = false, desc = "Extract Function" })
+-- vim.keymap.set({ "x" }, "rf", [[lua require('refactoring').refactor('Extract Function To File')]],
+-- { noremap = true, silent = true, expr = false, desc = "Extract Function To File" })
+-- vim.keymap.set({ "x" }, "rv", [[lua require('refactoring').refactor('Extract Variable')]],
+-- { noremap = true, silent = true, expr = false, desc = "Extract Variable" })
+-- vim.keymap.set({ "n" }, "rI", [[lua require('refactoring').refactor('Inline Variable')]],
+-- { noremap = true, silent = true, expr = false, desc = "Inline Variable" })
+-- vim.keymap.set({ "n", "x" }, "ri", [[lua require('refactoring').refactor('Inline Variable')]],
+-- { noremap = true, silent = true, expr = false, desc = "Inline Variable" })
+--
+-- vim.keymap.set({ "n" }, "rb", [[lua require('refactoring').refactor('Extract Block')]],
+-- { noremap = true, silent = true, expr = false, desc = "Extract Block" })
+-- vim.keymap.set({ "n" }, "rbf", [[lua require('refactoring').refactor('Extract Block To File')]],
+-- { noremap = true, silent = true, expr = false, desc = "Extract Block To File" })
--- Close the diagnostics location list
-vim.keymap.set('n', '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 = '*',
-})
diff --git a/lua/config/options.lua b/lua/config/options.lua
index 75e3f8d1..9ab0d2d3 100755
--- a/lua/config/options.lua
+++ b/lua/config/options.lua
@@ -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
+
diff --git a/lua/config/themes.lua b/lua/config/themes.lua
index 36fd72cb..e69de29b 100755
--- a/lua/config/themes.lua
+++ b/lua/config/themes.lua
@@ -1,8 +0,0 @@
--- return {
--- Theme inspired by Atom
--- 'navarasu/onedark.nvim',
--- priority = 1000,
--- config = function()
--- vim.cmd.colorscheme 'onedark'
--- end,
--- },
diff --git a/lua/config/utils.lua b/lua/config/utils.lua
index 8b137891..cc6161cf 100755
--- a/lua/config/utils.lua
+++ b/lua/config/utils.lua
@@ -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 ''
+ local visual_selection = require('config.utils').get_visual_selection()
+
+ return visual_selection ~= '' and visual_selection or word_under_cursor
+ end,
+}
diff --git a/lua/custom/plugins/auto-dark-mode.lua b/lua/custom/plugins/auto-dark-mode.lua
new file mode 100755
index 00000000..8a0d2c18
--- /dev/null
+++ b/lua/custom/plugins/auto-dark-mode.lua
@@ -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
+}
+
diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua
index d271227f..93085d0b 100755
--- a/lua/custom/plugins/autopairs.lua
+++ b/lua/custom/plugins/autopairs.lua
@@ -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,
}
+
diff --git a/lua/custom/plugins/cmp.lua b/lua/custom/plugins/cmp.lua
index b7126dac..84a9e5e2 100755
--- a/lua/custom/plugins/cmp.lua
+++ b/lua/custom/plugins/cmp.lua
@@ -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({
[''] = cmp.mapping.select_next_item(),
[''] = cmp.mapping.select_prev_item(),
[''] = cmp.mapping.scroll_docs(-4),
[''] = cmp.mapping.scroll_docs(4),
- [''] = cmp.mapping.complete {},
- [''] = cmp.mapping.confirm {
- behavior = cmp.ConfirmBehavior.Replace,
- select = true,
- },
- [''] = cmp.mapping(function(fallback)
+ [''] = cmp.mapping.complete(),
+ [''] = cmp.mapping.confirm({ select = true }),
+ [''] = 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' }),
- [''] = cmp.mapping(function(fallback)
+ [''] = 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',
- },
+ [''] = 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,
}
+
diff --git a/lua/custom/plugins/comments.lua b/lua/custom/plugins/comments.lua
index 44766d55..4db08198 100755
--- a/lua/custom/plugins/comments.lua
+++ b/lua/custom/plugins/comments.lua
@@ -1,5 +1,5 @@
return {
'numToStr/Comment.nvim',
opts = {},
- lazy = false
}
+
diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua
old mode 100644
new mode 100755
index 1a804873..8631b195
--- a/lua/custom/plugins/copilot.lua
+++ b/lua/custom/plugins/copilot.lua
@@ -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 = '',
+ accept_line = '',
+ next = 'M-[',
+ previous = 'M-]',
+ },
+ },
+ },
}
+
diff --git a/lua/custom/plugins/dadbod.lua b/lua/custom/plugins/dadbod.lua
new file mode 100755
index 00000000..688a9134
--- /dev/null
+++ b/lua/custom/plugins/dadbod.lua
@@ -0,0 +1,14 @@
+return {
+ 'tpope/vim-dadbod',
+ dependencies = {
+ 'kristijanhusak/vim-dadbod-ui',
+ 'kristijanhusak/vim-dadbod-completion',
+ },
+ keys = {
+ { 'du', 'DBUIToggle', { desc = 'Toggle dadbod', noremap = true } },
+ },
+ init = function()
+ vim.g.db_ui_use_nerd_fonts = 1
+ end,
+}
+
diff --git a/lua/custom/plugins/dap.lua b/lua/custom/plugins/dap.lua
new file mode 100755
index 00000000..797e65e2
--- /dev/null
+++ b/lua/custom/plugins/dap.lua
@@ -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', 'dc', ':lua require"dap".continue()', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'ds', ':lua require"dap".step_over()', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'di', ':lua require"dap".step_into()', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'do', ':lua require"dap".step_out()', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'db', ':lua require"dap".toggle_breakpoint()', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'dr', ':lua require"dap".repl.open()', { noremap = true, silent = true })
+ vim.api.nvim_set_keymap('n', 'du', ':lua require"dapui".toggle()', { 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', 'dr', ':RustDebuggables', { noremap = true, silent = true })
+ -- Keybind for RustHoverActions
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', ':RustHoverActions', { 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', 'dc', ':lua require"dap".continue()' },
+ { 'n', 'ds', ':lua require"dap".step_over()' },
+ { 'n', 'di', ':lua require"dap".step_into()' },
+ { 'n', 'do', ':lua require"dap".step_out()' },
+ { 'n', 'db', ':lua require"dap".toggle_breakpoint()' },
+ { 'n', 'dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))' },
+ { 'n', 'dr', ':lua require"dap".repl.open()' },
+ { 'n', 'du', ':lua require"dapui".toggle()' }
+ },
+ ft = { 'python', 'go', 'rust' }
+ }
+}
+
diff --git a/lua/custom/plugins/diffview.lua b/lua/custom/plugins/diffview.lua
new file mode 100755
index 00000000..ecc2b1bb
--- /dev/null
+++ b/lua/custom/plugins/diffview.lua
@@ -0,0 +1,6 @@
+return {
+ 'sindrets/diffview.nvim',
+ dependencies = { 'nvim-lua/plenary.nvim' },
+ opts = {},
+}
+
diff --git a/lua/custom/plugins/formatting.lua b/lua/custom/plugins/formatting.lua
index 890fdb12..38b695a0 100755
--- a/lua/custom/plugins/formatting.lua
+++ b/lua/custom/plugins/formatting.lua
@@ -1,25 +1,41 @@
return {
- "stevearc/conform.nvim",
- event = { "BufReadPre", "BufNewFile" },
- config = function()
- local conform = require("conform")
+ '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' },
+ }
- conform.setup({
- formatters_by_ft = {
- python = { "isort", "black" },
- },
+ 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" }, "mp", function()
- conform.format({
- lsp_fallback = true,
- async = false,
- timeout_ms = 500,
- })
- end, { desc = "Format file or range (in visual mode)" })
+
+ require('mason-tool-installer').setup({
+ ensure_installed = {
+ 'stylua',
+ 'ruff',
+ 'isort',
+ 'black',
+ 'gofumpt',
+ 'goimports',
+ },
+ })
end,
}
+
diff --git a/lua/custom/plugins/fugitive.lua b/lua/custom/plugins/fugitive.lua
index 72711a58..a686da67 100755
--- a/lua/custom/plugins/fugitive.lua
+++ b/lua/custom/plugins/fugitive.lua
@@ -2,5 +2,46 @@ return {
'tpope/vim-fugitive',
config = function()
vim.keymap.set('n', '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', 'p', function()
+ vim.cmd.Git 'push'
+ end, opts)
+
+ -- rebase always
+ vim.keymap.set('n', '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', 't', ':Git push -u origin ', opts)
+ end,
+ })
+
+ vim.keymap.set('n', 'gu', 'diffget //2')
+ vim.keymap.set('n', 'gh', 'diffget //3')
+ 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,
}
+
diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua
index 0a64658b..cb877b33 100755
--- a/lua/custom/plugins/gitsigns.lua
+++ b/lua/custom/plugins/gitsigns.lua
@@ -1,32 +1,45 @@
return {
- -- Adds git related signs to the gutter, as well as utilities for managing changes
- 'lewis6991/gitsigns.nvim',
- opts = {
- -- See `:help gitsigns.txt`
- signs = {
- add = { text = '+' },
- change = { text = '~' },
- delete = { text = '_' },
- topdelete = { text = 'โพ' },
- changedelete = { text = '~' },
- },
- on_attach = function(bufnr)
- vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, {
- buffer = bufnr, desc = 'Preview git hunk'
- })
+ -- Lazy load gitsigns.nvim only if in a git repository
+ {
+ 'lewis6991/gitsigns.nvim',
+ opts = {
+ -- Configuration options for gitsigns.nvim
+ signs = {
+ add = { text = '+' },
+ change = { text = '~' },
+ delete = { text = '_' },
+ topdelete = { text = 'โพ' },
+ changedelete = { text = '~' },
+ },
+ -- on_attach function executed when the plugin is attached to a buffer
+ on_attach = function(bufnr)
+ vim.keymap.set('n', '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
- vim.keymap.set({ 'n', 'v' }, ']c', function()
- if vim.wo.diff then return ']c' end
- vim.schedule(function() gs.next_hunk() end)
- return ''
- 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)
- return ''
- end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
- end,
+ -- 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)
+ return ''
+ 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)
+ return ''
+ end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' })
+ end,
+ },
},
}
+
diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua
index 18216332..a7123012 100755
--- a/lua/custom/plugins/harpoon.lua
+++ b/lua/custom/plugins/harpoon.lua
@@ -1,15 +1,40 @@
return {
- "theprimeagen/harpoon",
- config = function()
- local mark = require("harpoon.mark")
- local ui = require("harpoon.ui")
+ 'theprimeagen/harpoon',
+ branch = 'harpoon2',
+ dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim' },
+ config = function()
+ local harpoon = require 'harpoon'
- vim.keymap.set("n", "a", mark.add_file, { desc = "[A]dd file harpoon" })
- vim.keymap.set("n", "", ui.toggle_quick_menu, { desc = "Go to harpoon" })
+ harpoon:setup()
- vim.keymap.set("n", "", function() ui.nav_file(1) end)
- vim.keymap.set("n", "", function() ui.nav_file(2) end)
- vim.keymap.set("n", "", function() ui.nav_file(3) end)
- vim.keymap.set("n", "", function() ui.nav_file(4) end)
- end,
+ vim.keymap.set('n', 'a', function()
+ harpoon:list():add()
+ end, { desc = 'Add file to harpoon' })
+ vim.keymap.set('n', '', function()
+ harpoon.ui:toggle_quick_menu(harpoon:list())
+ end, { desc = 'Open harpoon window' })
+ -- vim.keymap.set("n", "", function() toggle_telescope(harpoon.list()) end, { desc = "Open harpoon window" })
+
+ vim.keymap.set('n', '', function()
+ harpoon:list():select(1)
+ end)
+ vim.keymap.set('n', '', function()
+ harpoon:list():select(2)
+ end)
+ vim.keymap.set('n', '', function()
+ harpoon:list():select(3)
+ end)
+ vim.keymap.set('n', '', function()
+ harpoon:list():select(4)
+ end)
+
+ -- Toggle previous & next buffers stored within Harpoon list
+ vim.keymap.set('n', '', function()
+ harpoon:list():prev()
+ end)
+ vim.keymap.set('n', '', function()
+ harpoon:list():next()
+ end)
+ end,
}
+
diff --git a/lua/custom/plugins/indent.lua b/lua/custom/plugins/indent.lua
index 2a83c657..02f5d094 100755
--- a/lua/custom/plugins/indent.lua
+++ b/lua/custom/plugins/indent.lua
@@ -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 },
},
}
+
diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua
deleted file mode 100755
index be0eb9d8..00000000
--- a/lua/custom/plugins/init.lua
+++ /dev/null
@@ -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 {}
diff --git a/lua/custom/plugins/linting.lua b/lua/custom/plugins/linting.lua
index 282ff8af..d7933cd0 100755
--- a/lua/custom/plugins/linting.lua
+++ b/lua/custom/plugins/linting.lua
@@ -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', '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,
diff --git a/lua/custom/plugins/lsp-config.lua b/lua/custom/plugins/lsp-config.lua
index 21b6feda..c226d213 100755
--- a/lua/custom/plugins/lsp-config.lua
+++ b/lua/custom/plugins/lsp-config.lua
@@ -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('rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('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('D', vim.lsp.buf.type_definition, 'Type [D]efinition')
+ nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('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('