NeoVim & VIM

- Testing setup through neotest plugin
- Spellcheck enabled on markdown and text files
- Diagnosis summary through trouble plugin
- Code completion keybindings improved
- Auto-formatting through conform plugin
- Reactjs context aware commenting through nvim-ts-context-commentstring
- Auto HTML tag completion through nvim-ts-autotag
- CSS color highlight through nvim-highlight-colors
- Lualine: breadcrumbs, git status, single line
- Auto restore neovim sessions
- Better keyboard maps

Shell
- Aliases now load from .bashrc or .zshrc
- Bash & zsh shortcuts to easy open and create projects
- zoxide instead of cd when installed
- bootstrap.sh shellhardened
This commit is contained in:
Pratik Tripathy
2024-02-06 23:24:27 +05:30
parent 6b2d076cdc
commit b0efae3730
36 changed files with 1159 additions and 415 deletions

3
.gitignore vendored
View File

@@ -96,3 +96,6 @@ dist-ssr
*backup *backup
*undo *undo
*sessions *sessions
*.bak
nvim_switch/
*kitty/*.py

View File

@@ -19,4 +19,3 @@ Example: bash ./bootstrap.sh -q --create-links
## Why `--create-links`? ## Why `--create-links`?
I have multiple Linux installations on my machine. Linking it from one place (this repository) keeps things tidy. Also, changes to dotfiles automatically get applied to all the distros. I have multiple Linux installations on my machine. Linking it from one place (this repository) keeps things tidy. Also, changes to dotfiles automatically get applied to all the distros.

View File

@@ -13,7 +13,7 @@ QUIET="n"
CREATE_LINKS="n" CREATE_LINKS="n"
usage() { usage() {
if [ -n "$1" ]; then if [ "$1" != "" ]; then
echo "" echo ""
echo -e "${CRED}$1${CEND}\n" echo -e "${CRED}$1${CEND}\n"
fi fi
@@ -29,32 +29,32 @@ usage() {
} }
place_dotfile_at_target_location() { place_dotfile_at_target_location() {
local source_file_location="$1" source_file_location="$1"
local file_target_location="$2" file_target_location="$2"
local TS="$3" TS="$3"
# echo "${source_file_location}" # echo "${source_file_location}"
# echo "${file_target_location}" # echo "${file_target_location}"
# To avoid over writing existing dot file, we rename them # To avoid over writing existing dot file, we rename them
# Appending the timestamp to file name # Appending the timestamp to file name
if [ -f "${file_target_location}" ] || [ -L "${file_target_location}" ]; then if [ -f "$file_target_location" ] || [ -L "$file_target_location" ]; then
# echo "mv ${file_target_location} ${file_target_location}_${TS}" && [[ "$QUIET" == "n" ]] && echo "Existing dotfile renamed to ${file_target_location}_${TS}" # echo "mv ${file_target_location} ${file_target_location}_${TS}" && [[ "$QUIET" == "n" ]] && echo "Existing dotfile renamed to ${file_target_location}_${TS}"
mv "${file_target_location}" "${file_target_location}_${TS}" && [ "$QUIET" = "n" ] && echo "Existing setting renamed to ${file_target_location}_${TS}" mv "$file_target_location" "${file_target_location}_${TS}" && [ "$QUIET" = "n" ] && echo "Existing setting renamed to ${file_target_location}_${TS}"
fi fi
local target_directory target_directory
target_directory=$(dirname "${file_target_location}") target_directory=$(dirname "$file_target_location")
if [ ! -d "${target_directory}" ]; then if [ ! -d "$target_directory" ]; then
mkdir -p "${target_directory}" && [ "$QUIET" = "n" ] && echo "Directory ${target_directory} created" mkdir -p "$target_directory" && [ "$QUIET" = "n" ] && echo "Directory ${target_directory} created"
fi fi
if [ "$CREATE_LINKS" = "y" ]; then if [ "$CREATE_LINKS" = "y" ]; then
# echo "ln -s ${source_file_location} ${target_directory}" # echo "ln -s ${source_file_location} ${target_directory}"
ln -s "${source_file_location}" "${target_directory}" && [ "$QUIET" = "n" ] && echo "Linked ${file_target_location}" ln -s "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Linked ${file_target_location}"
else else
# echo "cp ${source_file_location} ${target_directory}" # echo "cp ${source_file_location} ${target_directory}"
cp "${source_file_location}" "${target_directory}" && [ "$QUIET" = "n" ] && echo "Copied ${file_target_location}" cp "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Copied ${file_target_location}"
fi fi
} }
@@ -92,6 +92,7 @@ main() {
;; ;;
*) *)
OS="UNSUPPORTED" OS="UNSUPPORTED"
;;
esac esac
TS=$(date '+%d_%m_%Y-%H_%M_%S') TS=$(date '+%d_%m_%Y-%H_%M_%S')
@@ -100,18 +101,18 @@ main() {
cd -P "$(dirname "$0")" || exit cd -P "$(dirname "$0")" || exit
# Copy all files in "Common" dotfiles to $HOME directory ("~") # Copy all files in "Common" dotfiles to $HOME directory ("~")
find "./common" -type f ! -path '*.DS_Store' ! -path '*.directory' -print0 | while IFS= read -r -d '' file; find "./common" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file;
do do
local file_target_location="${file/.\/common/$HOME}" file_target_location="${file/.\/common/$HOME}"
local source_file_location="${file/./$PWD}" source_file_location="${file/./$PWD}"
place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS" place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS"
done done
# Copy platform specific files to $HOME directory ("~") # Copy platform specific files to $HOME directory ("~")
find "./${OS}" -type f ! -path '*.DS_Store' ! -path '*.directory' -print0 | while IFS= read -r -d '' file; find "./${OS}" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file;
do do
local file_target_location="${file/.\/${OS}/$HOME}" file_target_location="${file/.\/${OS}/$HOME}"
local source_file_location="${file/./$PWD}" source_file_location="${file/./$PWD}"
place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS" place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS"
done done
} }

View File

@@ -179,10 +179,17 @@ HISTFILE="$XDG_STATE_HOME/shell/bash_history"
[ ! -f "$XDG_CONFIG_HOME/exercism/exercism_completion.bash" ] || source "$XDG_CONFIG_HOME/exercism/exercism_completion.bash" [ ! -f "$XDG_CONFIG_HOME/exercism/exercism_completion.bash" ] || source "$XDG_CONFIG_HOME/exercism/exercism_completion.bash"
if command -v zoxide >/dev/null; then if command -v zoxide >/dev/null; then
eval "$(zoxide init bash)" eval "$(zoxide init --cmd cd bash)"
fi fi
# [ctrl+r]:replaces shell command search # [ctrl+r]:replaces shell command search
# [ctrl+t]:fzf & over the files & directories under the current one & paste it to prompt # [ctrl+t]:fzf & over the files & directories under the current one & paste it to prompt
# [alt+c] :fzf & cd into a directory under the current one # [alt+c] :fzf & cd into a directory under the current one
[ -f $XDG_STATE_HOME/shell/fzf.bash ] && source $XDG_STATE_HOME/shell/fzf.bash [ -f $XDG_STATE_HOME/shell/fzf.bash ] && source $XDG_STATE_HOME/shell/fzf.bash
# Source aliases and shell functions
for alias_file in "$XDG_CONFIG_HOME"/shell/*.sh; do source "$alias_file"; done
# TIP: Following should be executed AFTER the aliases are sourced
command -v op >/dev/null && bind '"^O":"op\n"' # Fuzzyfind projects and open in nvim
command -v pnew >/dev/null && bind '"^[o":"pnew\n"' # Create a new project quickly

View File

@@ -2,8 +2,6 @@
# TODO: # TODO:
# - Display current directory on OS title: even when nvim or any other forground app is running # - Display current directory on OS title: even when nvim or any other forground app is running
# - Vim keymaps <ctrl>+hjkl to move around splits: https://github.com/knubie/vim-kitty-navigator
# - OR <ctrl+shift>+ <arrow_keys>??? in sync with konsole???
# - <Ctrl+shift> [/] to decrease/increase split size # - <Ctrl+shift> [/] to decrease/increase split size
#: Fonts {{{ #: Fonts {{{
@@ -434,11 +432,11 @@ scrollback_pager nvim -c 'set ft=man'
# Enable kitty scrollback.nvim plugin # Enable kitty scrollback.nvim plugin
allow_remote_control yes allow_remote_control yes
listen_on unix:/tmp/kitty listen_on unix:@mykitty
shell_integration enabled no-sudo no-complete shell_integration enabled no-sudo no-complete
action_alias kitty_scrollback_nvim kitten /home/pratik/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args --clean --noplugin -n action_alias kitty_scrollback_nvim kitten /home/pratik/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args --clean --noplugin -n
map kitty_mod+h kitty_scrollback_nvim map kitty_mod+g kitty_scrollback_nvim
map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output map kitty_mod+alt+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
mouse_map kitty_mod+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_cmd_output mouse_map kitty_mod+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
map kitty_mod+f7 show_kitty_env_vars map kitty_mod+f7 show_kitty_env_vars
@@ -1029,14 +1027,32 @@ enable_audio_bell no
# Hide title bar # Hide title bar
hide_window_decorations yes hide_window_decorations yes
window_border_width 0.2pt window_border_width 0.2pt
# New windows open in the same directory as the current window
map ctrl+shift+enter new_window_with_cwd # New splits open in the same directory as the current window
map shift+F1 new_window_with_cwd
map kitty_mod+enter new_window_with_cwd
map shift+F2 toggle_layout stack # Zoom the current window
enabled_layouts fat:bias=75;full_size=1,stack,tall:bias=50;full_size=2 enabled_layouts fat:bias=75;full_size=1,stack,tall:bias=50;full_size=2
map F11 toggle_layout stack map F11 toggle_layout stack
# Open nvim on the current directory with ctrl+shift+o # Open nvim on the current directory with ctrl+shift+o
map ctrl+shift+o launch --cwd=current --type=tab nvim map kitty_mod+o launch --cwd=current --type=tab nvim
# Sync split navigation with VIM: https://github.com/knubie/vim-kitty-navigator
map ctrl+shift+j kitten pass_keys.py bottom ctrl+shift+j
map ctrl+shift+k kitten pass_keys.py top ctrl+shift+k
map ctrl+shift+h kitten pass_keys.py left ctrl+shift+h
map ctrl+shift+l kitten pass_keys.py right ctrl+shift+l
map ctrl+shift+j kitten pass_keys.py bottom ctrl+shift+j "^.* - nvim$"
map ctrl+shift+k kitten pass_keys.py top ctrl+shift+k "^.* - nvim$"
map ctrl+shift+h kitten pass_keys.py left ctrl+shift+h "^.* - nvim$"
map ctrl+shift+l kitten pass_keys.py right ctrl+shift+l "^.* - nvim$"
# Redundant, they are used for scrollback.nvim as well
# But, this would work even if we uninstall scrollback.nvim
listen_on unix:@mykitty
allow_remote_control yes
#: Tab bar {{{ #: Tab bar {{{
@@ -1896,8 +1912,8 @@ update_check_interval 0
#: cause all invocations of the hints kitten to have the --hints- #: cause all invocations of the hints kitten to have the --hints-
#: offset=0 option applied. #: offset=0 option applied.
map ctrl+shift+p nth_window -1 map kitty_mod+p nth_window -1
map ctrl+shift+n nth_window +1 map kitty_mod+n nth_window +1
#: Clipboard {{{ #: Clipboard {{{

View File

@@ -9,13 +9,18 @@
-- TIP: Keymap structure: -- TIP: Keymap structure:
-- b: buffer -- b: buffer
-- g: git/github -- g: git/github
-- c: Coding things -- c: Coding Stuff
-- e: explorer -- e: explorer
-- f: list & find something -- l: list & find something
-- s: Grep/Search over something -- s: Grep/Search over something
-- x: close/dismiss something -- x: close/dismiss something
-- r: restore sessions
-- l: List some stuff -- l: List some stuff
-- d: [D]iagnostics
-- t: Test runner stuff
-- TODO:
-- Reduce noice timeout
-- WhichKey add hints
-- Load keymaps & options -- Load keymaps & options
require("config") require("config")
@@ -43,6 +48,9 @@ require("lazy").setup({
change_detection = { change_detection = {
notify = false, notify = false,
}, },
build = {
warn_on_override = true,
},
performance = { performance = {
rtp = { rtp = {
-- Disable some rtp plugins -- Disable some rtp plugins

View File

@@ -0,0 +1,20 @@
-- Auto reload existing session
vim.api.nvim_create_autocmd("VimEnter", {
group = vim.api.nvim_create_augroup("restore_session", { clear = true }),
callback = function()
-- If nvim started with arguments, do NOT restore
if vim.fn.argc() ~= 0 then return end
require("persistence").load()
end,
nested = true,
})
-- Enable spell check on markdown and text files
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("spell_check_text_files", { clear = true }),
pattern = { "markdown", "gitcommit", "text" },
callback = function()
vim.opt.spell = true
end,
nested = true,
})

View File

@@ -1,2 +1,3 @@
require("config.keymaps") require("config.keymaps")
require("config.options") require("config.options")
require("config.autocmd")

View File

@@ -4,7 +4,14 @@ if vim.loop.fs_stat(vim_mappings) then
vim.cmd("source " .. vim_mappings) vim.cmd("source " .. vim_mappings)
end end
vim.keymap.set({ "n" }, "<leader><CR>", function()
vim.cmd("source " .. vim.fn.expand(vim.fn.stdpath("config") .. "/init.lua"))
end, { desc = "Apply NVIM config changes" })
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "Copy to system clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p', { desc = "Paste from system clipboard" })
vim.keymap.set({ "n" }, "<C-c>", "<cmd> %y+ <CR>", { desc = "Copy entire content of the current buffer" }) vim.keymap.set({ "n" }, "<C-c>", "<cmd> %y+ <CR>", { desc = "Copy entire content of the current buffer" })
vim.keymap.set("n", "<leader>fn", "<cmd>enew<CR>", { desc = "Create new file/buffer" }) vim.keymap.set("n", "<leader>fn", "<cmd>enew<CR>", { desc = "Create new file/buffer" })
-- Remap for dealing with word wrap -- Remap for dealing with word wrap
@@ -29,6 +36,12 @@ vim.keymap.set("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move line up" })
vim.keymap.set("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move line down" }) vim.keymap.set("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move line down" })
vim.keymap.set("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move line up" }) vim.keymap.set("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move line up" })
vim.keymap.set("i", "<C-BS>", "<C-g>u<C-w>", { desc = "Add undo breakpoint and delete last word" })
vim.keymap.set("i", ",", ",<C-g>u", { desc = "Auto add undo breakpoints on ','" })
vim.keymap.set("i", ".", ".<C-g>u", { desc = "Auto add undo breakpoints on '.'" })
vim.keymap.set("i", ";", ";<C-g>u", { desc = "Auto add undo breakpoints on ';'" })
vim.keymap.set("i", "\r", "\r<C-g>u", { desc = "Auto add undo breakpoints on new lines" })
-- Traverse Buffer -- Traverse Buffer
vim.keymap.set("n", "<Tab>", "<cmd>bnext<CR>", { desc = "Switch to next buffer" }) vim.keymap.set("n", "<Tab>", "<cmd>bnext<CR>", { desc = "Switch to next buffer" })
vim.keymap.set("n", "<S-Tab>", "<cmd>bprevious<CR>", { desc = "Switch to previous buffer" }) vim.keymap.set("n", "<S-Tab>", "<cmd>bprevious<CR>", { desc = "Switch to previous buffer" })
@@ -38,7 +51,7 @@ vim.keymap.set({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Sav
vim.keymap.set({ "i", "x", "n", "s" }, "<C-q>", "<cmd>wqa<cr><esc>", { desc = "Save all files and Quit Neovim" }) vim.keymap.set({ "i", "x", "n", "s" }, "<C-q>", "<cmd>wqa<cr><esc>", { desc = "Save all files and Quit Neovim" })
-- Close Current Buffer -- Close Current Buffer
vim.keymap.set({ "n", "v" }, "<leader>bx", function() vim.keymap.set({ "n", "v" }, "<leader>xb", function()
if vim.bo.modified then if vim.bo.modified then
vim.cmd.write() vim.cmd.write()
end end
@@ -46,17 +59,32 @@ vim.keymap.set({ "n", "v" }, "<leader>bx", function()
end, { desc = "Save and close current buffer" }) end, { desc = "Save and close current buffer" })
-- Traverse quickfix -- Traverse quickfix
-- TODO: Friendly message when no quickfix
vim.keymap.set("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) vim.keymap.set("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" })
vim.keymap.set("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) vim.keymap.set("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" })
-- Clear searches -- Clear searches
vim.keymap.set({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" }) vim.keymap.set({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
vim.keymap.set("n", "<leader>/", "<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>", vim.keymap.set("n", "<leader>/", "<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>", { desc = "Redraw / clear hlsearch / diff update" })
{ desc = "Redraw / clear hlsearch / diff update" })
-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n
vim.keymap.set("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next search result" }) vim.keymap.set("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next search result" })
vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) vim.keymap.set({ "x", "o" }, "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
vim.keymap.set("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev search result" }) vim.keymap.set("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev search result" })
vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) vim.keymap.set({ "x", "o" }, "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
-- diagnostic: From LazyVim
local diagnostic_goto = function(next, severity)
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
severity = severity and vim.diagnostic.severity[severity] or nil
return function()
go({ severity = severity })
end
end
vim.keymap.set("n", "<leader>cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
vim.keymap.set("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" })
vim.keymap.set("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" })
vim.keymap.set("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" })
vim.keymap.set("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" })
vim.keymap.set("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" })
vim.keymap.set("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })

View File

@@ -0,0 +1,121 @@
-- Required mostly be lualine plugin
-- Copied from Lazyvim
local M = {
icons = {
misc = {
dots = "󰇘",
},
dap = {
Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" },
Breakpoint = "",
BreakpointCondition = "",
BreakpointRejected = { "", "DiagnosticError" },
LogPoint = ".>",
},
diagnostics = { Error = "", Warn = "", Hint = "", Info = "" },
git = { added = "", modified = "", removed = "" },
kinds = {
Array = "",
Boolean = "󰨙 ",
Class = "",
Codeium = "󰘦 ",
Color = "",
Control = "",
Collapsed = "",
Constant = "󰏿 ",
Constructor = "",
Copilot = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "󰈙 ",
Folder = "",
Function = "󰊕 ",
Interface = "",
Key = "󰌋 ",
Keyword = "",
Method = "󰊕 ",
Module = "",
Namespace = "󰦮 ",
Null = "󰟢 ",
Number = "󰎠 ",
Object = "",
Operator = "",
Package = "",
Property = "",
Reference = "",
Snippet = "",
String = "",
Struct = "󰆼 ",
TabNine = "󰏚 ",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "󰀫 ",
},
},
}
function M.fg(name)
---@type {foreground?:number}?
---@diagnostic disable-next-line: deprecated
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
---@diagnostic disable-next-line: undefined-field
local fg = hl and (hl.fg or hl.foreground)
return fg and { fg = string.format("#%06x", fg) } or nil
end
---@param opts? lsp.Client.filter
function M.get_clients(opts)
local ret = {} ---@type lsp.Client[]
if vim.lsp.get_clients then
ret = vim.lsp.get_clients(opts)
else
---@diagnostic disable-next-line: deprecated
ret = vim.lsp.get_active_clients(opts)
if opts and opts.method then
---@param client lsp.Client
ret = vim.tbl_filter(function(client)
return client.supports_method(opts.method, { bufnr = opts.bufnr })
end, ret)
end
end
return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret
end
---@param from string
---@param to string
function M.on_rename(from, to)
local clients = M.get_clients()
for _, client in ipairs(clients) do
if client.supports_method("workspace/willRenameFiles") then
---@diagnostic disable-next-line: invisible
local resp = client.request_sync("workspace/willRenameFiles", {
files = {
{
oldUri = vim.uri_from_fname(from),
newUri = vim.uri_from_fname(to),
},
},
}, 1000, 0)
if resp and resp.result ~= nil then
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
end
end
end
end
---@param on_attach fun(client, buffer)
function M.on_lsp_attach(on_attach)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end
return M

View File

@@ -1,4 +1,7 @@
return { return {
-- TODO: Figureout how to add custom snippets
{ {
-- Autocompletion -- Autocompletion
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
@@ -10,17 +13,17 @@ return {
-- Adds LSP completion capabilities -- Adds LSP completion capabilities
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
-- Adds a number of user-friendly snippets -- Adds a number of user-friendly snippets
"rafamadriz/friendly-snippets", "rafamadriz/friendly-snippets",
-- Autocompletion for commands
"hrsh7th/cmp-cmdline",
}, },
config = function() config = function()
-- [[ Configure nvim-cmp ]] -- [[ Configure nvim-cmp ]]
-- See `:help cmp` -- See `:help cmp`
-- vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
local cmp = require("cmp") local cmp = require("cmp")
local defaults = require("cmp.config.default")()
local luasnip = require("luasnip") local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
luasnip.config.setup({}) luasnip.config.setup({})
@@ -37,58 +40,64 @@ return {
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-f>"] = cmp.mapping.scroll_docs(4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-u>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}), ["<C-Space>"] = cmp.mapping.complete({}),
["<C-x>"] = cmp.mapping.abort(),
-- Enter to perform the completion
["<CR>"] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm({
select = true,
}),
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
}), }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}), }),
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "path" }, { name = "path" },
{ { name = "buffer" } },
}, },
-- experimental = {
-- ghost_text = {
-- hl_group = "CmpGhostText",
-- },
-- },
sorting = defaults.sorting,
}) })
end,
},
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
}
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ {
name = "cmdline", "L4MON4D3/LuaSnip",
option = { keys = {
ignore_cmds = { "Man", "!" } {
} "<tab>",
} function()
}) return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
}) end,
end expr = true,
silent = true,
mode = "i",
},
{
"<tab>",
function()
require("luasnip").jump(1)
end,
mode = "s",
},
{
"<s-tab>",
function()
require("luasnip").jump(-1)
end,
mode = { "i", "s" },
},
},
}, },
} }

View File

@@ -1,10 +1,5 @@
-- debug.lua
--
-- Shows how to use the DAP plugin to debug your code.
--
-- Primarily focused on configuring the debugger for Go, but can -- Primarily focused on configuring the debugger for Go, but can
-- be extended to other languages as well. That's why it's called -- be extended to other languages as well.
-- kickstart.nvim and not kitchen-sink.nvim ;)
return { return {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
@@ -24,23 +19,20 @@ return {
local dapui = require("dapui") local dapui = require("dapui")
require("mason-nvim-dap").setup({ require("mason-nvim-dap").setup({
-- Makes a best effort to setup the various debuggers with -- Makes a best effort to setup the various debuggers with reasonable debug configurations
-- reasonable debug configurations
automatic_setup = true, automatic_setup = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information -- see mason-nvim-dap README for more information
handlers = {}, handlers = {},
-- You'll need to check that you have the required things installed -- You'll need to check that you have the required things installed online
-- online, please don't ask me how to install them :)
ensure_installed = { ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want -- Update this to ensure that you have the debuggers for the langs you want
"delve", -- "delve",
-- TODO: Rust, C#, TS/JS, Python
}, },
}) })
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Start/Continue" }) vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Start/Continue" })
vim.keymap.set("n", "<F1>", dap.step_into, { desc = "Debug: Step Into" }) vim.keymap.set("n", "<F1>", dap.step_into, { desc = "Debug: Step Into" })
vim.keymap.set("n", "<F2>", dap.step_over, { desc = "Debug: Step Over" }) vim.keymap.set("n", "<F2>", dap.step_over, { desc = "Debug: Step Over" })
@@ -50,12 +42,9 @@ return {
dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end, { desc = "Debug: Set Breakpoint" }) end, { desc = "Debug: Set Breakpoint" })
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui| -- For more information, see |:help nvim-dap-ui|
dapui.setup({ dapui.setup({
-- Set icons to characters that are more likely to work in every terminal. -- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = "", collapsed = "", current_frame = "*" }, icons = { expanded = "", collapsed = "", current_frame = "*" },
controls = { controls = {
icons = { icons = {
@@ -80,6 +69,7 @@ return {
dap.listeners.before.event_exited["dapui_config"] = dapui.close dap.listeners.before.event_exited["dapui_config"] = dapui.close
-- Install golang specific config -- Install golang specific config
require("dap-go").setup() -- require("dap-go").setup()
-- TODO: Rust, C#, TS/JS, Python
end, end,
} }

View File

@@ -1,70 +1,51 @@
-- autoformat.lua
return { return {
"neovim/nvim-lspconfig", {
"stevearc/conform.nvim",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function() config = function()
-- Switch for controlling whether you want autoformatting. local conform = require("conform")
-- Use :KickstartFormatToggle to toggle autoformatting on or off
local format_is_enabled = true
vim.api.nvim_create_user_command("KickstartFormatToggle", function()
format_is_enabled = not format_is_enabled
print("Setting autoformatting to: " .. tostring(format_is_enabled))
end, {})
-- Create an augroup that is used for managing our formatting autocmds. conform.setup({
-- We need one augroup per client to make sure that multiple clients formatters_by_ft = {
-- can attach to the same buffer without interfering with each other. javascript = { { "prettierd", "prettier" } },
local _augroups = {} typescript = { { "prettierd", "prettier" } },
local get_augroup = function(client) javascriptreact = { { "prettierd", "prettier" } },
if not _augroups[client.id] then typescriptreact = { { "prettierd", "prettier" } },
local group_name = "kickstart-lsp-format-" .. client.name svelte = { { "prettierd", "prettier" } },
local id = vim.api.nvim_create_augroup(group_name, { clear = true }) css = { { "prettierd", "prettier" } },
_augroups[client.id] = id html = { { "prettierd", "prettier" } },
end json = { { "prettierd", "prettier" } },
yaml = { { "prettierd", "prettier" } },
return _augroups[client.id] markdown = { { "prettierd", "prettier" } },
end graphql = { { "prettierd", "prettier" } },
lua = { "stylua" },
-- Whenever an LSP attaches to a buffer, we will run this function. python = { "black" },
-- sh = { "shfmt", "shellharden" },
-- See `:help LspAttach` for more information about this autocmd event. bash = { "shfmt", "shellharden" },
vim.api.nvim_create_autocmd("LspAttach", { zsh = { "shfmt", "shellharden" },
group = vim.api.nvim_create_augroup("kickstart-lsp-attach-format", { clear = true }), ["*"] = { "codespell" },
-- This is where we attach the autoformatting for reasonable clients ["_"] = { "trim_whitespace" },
callback = function(args) },
local client_id = args.data.client_id format_on_save = {
local client = vim.lsp.get_client_by_id(client_id) lsp_fallback = true,
local bufnr = args.buf
-- Only attach to clients that support document formatting
if not client.server_capabilities.documentFormattingProvider then
return
end
-- Tsserver usually works poorly. Sorry you work with bad languages
-- You can remove this line if you know what you're doing :)
if client.name == "tsserver" then
return
end
-- Create an autocmd that will run *before* we save the buffer.
-- Run the formatting command for the LSP that has just attached.
vim.api.nvim_create_autocmd("BufWritePre", {
group = get_augroup(client),
buffer = bufnr,
callback = function()
if not format_is_enabled then
return
end
vim.lsp.buf.format({
async = false, async = false,
filter = function(c) timeout_ms = 1000,
return c.id == client.id },
end, formatters = {
shfmt = {
prepend_args = { "-i", "4" },
},
},
}) })
end,
}) vim.keymap.set({ "n", "v" }, "<leader>cf", function()
end, conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 1000,
}) })
end, { desc = "[C]ode [F]ormat (visual selection)" })
end, end,
},
} }

View File

@@ -5,7 +5,16 @@ return {
{ "machakann/vim-highlightedyank" }, { "machakann/vim-highlightedyank" },
-- "gc" to comment visual regions/lines -- "gc" to comment visual regions/lines
{ "numToStr/Comment.nvim", opts = {} }, {
"numToStr/Comment.nvim",
config = function()
require("Comment").setup({
pre_hook = function()
return vim.bo.commentstring
end,
})
end,
},
-- auto pairs -- auto pairs
{ {
@@ -18,13 +27,21 @@ return {
{ {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
opts = { opts = {
indent = { char = "", tab_char = "", }, indent = { char = "", tab_char = "" },
scope = { enabled = false }, scope = { enabled = false },
exclude = { exclude = {
filetypes = { filetypes = {
"help", "alpha", "dashboard", "neo-tree", "help",
"Trouble", "trouble", "lazy", "mason", "alpha",
"notify", "toggleterm", "lazyterm", "dashboard",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
}, },
}, },
}, },
@@ -34,13 +51,18 @@ return {
-- Highlights the current level of indentation, and animates the highlighting. -- Highlights the current level of indentation, and animates the highlighting.
{ {
"echasnovski/mini.indentscope", "echasnovski/mini.indentscope",
opts = { symbol = "", options = { try_as_border = true }, }, opts = { symbol = "", options = { try_as_border = true } },
init = function() init = function()
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { pattern = {
"help", "neo-tree", "Trouble", "trouble", "help",
"lazy", "mason", "notify", "toggleterm", "neo-tree",
"lazyterm", "Trouble",
"trouble",
"lazy",
"mason",
"notify",
"toggleterm",
}, },
callback = function() callback = function()
vim.b.miniindentscope_disable = true vim.b.miniindentscope_disable = true
@@ -61,14 +83,134 @@ return {
}, },
}, },
keys = { keys = {
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, {
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, "]t",
function()
require("todo-comments").jump_next()
end,
desc = "Next todo comment",
},
{
"[t",
function()
require("todo-comments").jump_prev()
end,
desc = "Previous todo comment",
},
-- TODO: Find better keymaps for below { "<leader>dt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" },
-- { "<leader>xt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" }, { "<leader>dT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
-- { "<leader>xT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" }, -- TODO: Include hidden files
-- { "<leader>st", "<cmd>TodoTelescope<cr>", desc = "Todo" }, { "<leader>lt", "<cmd>TodoTelescope<cr>", desc = "List Todo" },
-- { "<leader>sT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme" }, { "<leader>lT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "List Todo/Fix/Fixme" },
},
},
-- better diagnostics list and others
{
"folke/trouble.nvim",
cmd = { "TroubleToggle", "Trouble" },
opts = { use_diagnostic_signs = true },
keys = {
{ "<leader>dx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
{ "<leader>dw", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
{ "<leader>dl", "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" },
{ "<leader>dq", "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" },
{
"[q",
function()
if require("trouble").is_open() then
require("trouble").previous({ skip_groups = true, jump = true })
else
local ok, err = pcall(vim.cmd.cprev)
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
end
end,
desc = "Previous trouble/quickfix item",
},
{
"]q",
function()
if require("trouble").is_open() then
require("trouble").next({ skip_groups = true, jump = true })
else
local ok, err = pcall(vim.cmd.cnext)
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
end
end,
desc = "Next trouble/quickfix item",
},
},
},
-- Inlay hints
{
"lvimuser/lsp-inlayhints.nvim",
config = function()
require("lsp-inlayhints").setup()
-- Lazy load on LspAttach
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})
vim.api.nvim_create_autocmd("LspAttach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
end,
})
end,
},
-- Lsp Breadcrumbs for lualine
{
"SmiteshP/nvim-navic",
lazy = true,
init = function()
vim.g.navic_silence = true
require("config.util").on_lsp_attach(function(client, buffer)
if client.supports_method("textDocument/documentSymbol") then
require("nvim-navic").attach(client, buffer)
end
end)
end,
opts = function()
return {
separator = " ",
highlight = true,
depth_limit = 5,
icons = require("config.util").icons.kinds,
lazy_update_context = true,
}
end,
},
{
"SmiteshP/nvim-navbuddy",
dependencies = {
"SmiteshP/nvim-navic",
"MunifTanjim/nui.nvim",
},
opts = {
lsp = { auto_attach = true },
icons = require("config.util").icons.kinds,
},
keys = {
{
"<leader>v",
function()
return require("nvim-navbuddy").open()
end,
desc = "N[v]igate through document symbols",
},
}, },
}, },
} }

View File

@@ -1,6 +1,6 @@
return { return {
{ "tpope/vim-fugitive", }, { "tpope/vim-fugitive" },
--{ "tpope/vim-rhubarb" }, --If fugitive.vim is the Git, rhubarb.vim is the Hub. --{ "tpope/vim-rhubarb" }, --If fugitive.vim is the Git, rhubarb.vim is the Hub.
{ {
@@ -14,6 +14,7 @@ return {
delete = { text = "_" }, delete = { text = "_" },
topdelete = { text = "" }, topdelete = { text = "" },
changedelete = { text = "~" }, changedelete = { text = "~" },
untracked = { text = "" },
}, },
on_attach = function(bufnr) on_attach = function(bufnr)
local gs = package.loaded.gitsigns local gs = package.loaded.gitsigns
@@ -52,6 +53,7 @@ return {
end, { desc = "reset git hunk" }) end, { desc = "reset git hunk" })
-- normal mode -- normal mode
map("n", "<leader>ghp", gs.preview_hunk, { desc = "preview git hunk" }) map("n", "<leader>ghp", gs.preview_hunk, { desc = "preview git hunk" })
map("n", "<leader>gp", gs.preview_hunk, { desc = "preview git hunk" })
map("n", "<leader>ghr", gs.reset_hunk, { desc = "git reset hunk" }) map("n", "<leader>ghr", gs.reset_hunk, { desc = "git reset hunk" })
map("n", "<leader>ghb", function() map("n", "<leader>ghb", function()

View File

@@ -0,0 +1,61 @@
return {
{
"mfussenegger/nvim-lint",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
-- Linters are only required for dynamically typed languages
lint.linters_by_ft = {
-- javascript = { "eslint_d" },
-- typescript = { "eslint_d" },
-- javascriptreact = { "eslint_d" },
-- typescriptreact = { "eslint_d" },
svelte = { "eslint_d" },
python = { "pylint" },
["*"] = { "codespell" },
}
-- Uncomment and use the below section in `package.json` to enable eslint_d
-- "eslintConfig": {
-- "root": true,
-- "extends": [
-- "eslint:recommended",
-- "plugin:@typescript-eslint/recommended"
-- ],
-- "parser": "@typescript-eslint/parser",
-- "parserOptions": {
-- "project": [
-- "./tsconfig.json"
-- ]
-- },
-- "plugins": [
-- "@typescript-eslint"
-- ],
-- "rules": {
-- "@typescript-eslint/strict-boolean-expressions": [
-- 2,
-- {
-- "allowString": false,
-- "allowNumber": false
-- }
-- ]
-- },
-- "ignorePatterns": [
-- "src/**/*.test.ts",
-- "src/frontend/generated/*"
-- ]
-- }
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
end,
},
}

View File

@@ -10,25 +10,15 @@ local on_attach = function(_, bufnr)
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end end
nmap("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") nmap("<leader>cr", vim.lsp.buf.rename, "[R]e[n]ame")
nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction") nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
nmap("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
nmap("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
-- See `:help K` for why this keymap -- 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 -- Lesser used LSP functionality
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") nmap("<leader>cws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") nmap("<leader>cwl", function()
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders") end, "[W]orkspace [L]ist Folders")
@@ -52,54 +42,84 @@ return {
{ "folke/neodev.nvim" }, { "folke/neodev.nvim" },
}, },
-- WARN: DO NOT do config here -- WARN: DO NOT do `config` here it would override `config` from coding-formatting.lua
-- That would override config from autoformat -- That's why we do the LSP config inside mason-lspconfig
}, },
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
config = function() config = function()
-- NOTE: We configure lsp here instead of in the lspconfig's config
-- Reason? read the warnings above
-- Configure LSP -- Configure LSP
-- mason-lspconfig requires that these setup functions are called in this order -- mason-lspconfig requires that these setup functions are called in this order
-- before setting up the servers. -- BEFORE setting up the servers.
require("mason").setup() require("mason").setup()
require("mason-lspconfig").setup() local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup()
-- Enable the following language servers -- Enable the following language servers
-- Add any additional override configuration in the following tables. They will be passed to -- Add any additional override configuration in the following tables. They will be passed to the `settings` field of the server config
-- the `settings` field of the server config. You must look up that documentation yourself. -- If you want to override the default filetypes that your language server will attach to you can define the property 'filetypes' to the map in question.
--
-- If you want to override the default filetypes that your language server will attach to you can
-- define the property 'filetypes' to the map in question.
local servers = { local servers = {
-- clangd = {}, -- clangd = {},
-- gopls = {}, -- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
lua_ls = { lua_ls = {
Lua = { Lua = {
workspace = { checkThirdParty = false }, workspace = { checkThirdParty = false },
telemetry = { enable = false }, telemetry = { enable = false },
-- hint = { enable = true },
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } }, -- diagnostics = { disable = { 'missing-fields' } },
}, },
}, },
-- Markdown
marksman = {},
awk_ls = {},
bashls = {
filetypes = { "sh", "bash", "zsh" },
},
cssls = {},
dockerls = {},
docker_compose_language_service = {},
html = { filetypes = { 'html', 'twig', 'hbs' } },
jsonls = {},
pyright = {},
rust_analyzer = {},
tsserver = {
typescript = {
inlayHints = {
-- includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
},
javascript = {
inlayHints = {
-- includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
}
},
} }
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
-- Ensure the servers above are installed
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup({ mason_lspconfig.setup({
ensure_installed = vim.tbl_keys(servers), ensure_installed = vim.tbl_keys(servers),
}) })
@@ -120,7 +140,6 @@ return {
{ {
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
opts = { opts = {
-- Options related to LSP progress subsystem
progress = { progress = {
poll_rate = 1, -- How and when to poll for progress messages poll_rate = 1, -- How and when to poll for progress messages
suppress_on_insert = true, -- Suppress new messages while in insert mode suppress_on_insert = true, -- Suppress new messages while in insert mode
@@ -128,14 +147,12 @@ return {
ignore_empty_message = true, -- Ignore new tasks that don't contain a message ignore_empty_message = true, -- Ignore new tasks that don't contain a message
ignore = {}, -- List of LSP servers to ignore ignore = {}, -- List of LSP servers to ignore
-- Options related to how LSP progress messages are displayed as notifications
display = { display = {
render_limit = 1, -- How many LSP messages to show at once render_limit = 1, -- How many LSP messages to show at once
skip_history = true, -- Whether progress notifications should be omitted from history skip_history = true, -- Whether progress notifications should be omitted from history
}, },
}, },
-- Options related to notification subsystem
notification = { notification = {
filter = vim.log.levels.WARN, -- Minimum notifications level filter = vim.log.levels.WARN, -- Minimum notifications level
}, },

View File

@@ -0,0 +1,33 @@
return {
-- Automatically add closing tags for HTML and JSX
{
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup()
end,
},
-- Intelligent commenting on JSX
{
"JoosepAlviste/nvim-ts-context-commentstring",
opts = {
options = {
enable_autocmd = false,
},
},
config = function()
vim.g.skip_ts_context_commentstring_module = true
end,
},
-- Highlight colors
{
"brenoprata10/nvim-highlight-colors",
setup = {
enable_tailwind = true,
},
config = function()
require("nvim-highlight-colors").setup()
end,
},
}

View File

@@ -0,0 +1,120 @@
return {
-- Test runner integration
-- Taken from LazyVim
{
"nvim-neotest/neotest",
dependencies = {
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter",
"marilari88/neotest-vitest"
},
opts = {
-- Do NOT add adapters here
-- Add it to opts.adapters inside config function
adapters = {},
status = { virtual_text = true },
output = { open_on_run = true },
quickfix = {
open = function()
if require("lazy.core.config").spec.plugins["trouble.nvim"] ~= nil then
require("trouble").open({ mode = "quickfix", focus = false })
else
vim.cmd("copen")
end
end,
},
},
config = function(_, opts)
local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({
virtual_text = {
format = function(diagnostic)
-- Replace newline and tab characters with space for more compact diagnostics
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+",
"")
return message
end,
},
}, neotest_ns)
-- WARN: Change the following code if we change lazy.nvim
if require("lazy.core.config").spec.plugins["trouble.nvim"] ~= nil then
opts.consumers = opts.consumers or {}
-- Refresh and auto close trouble after running tests
---@type neotest.Consumer
opts.consumers.trouble = function(client)
client.listeners.results = function(adapter_id, results, partial)
if partial then
return
end
local tree = assert(client:get_position(nil, { adapter = adapter_id }))
local failed = 0
for pos_id, result in pairs(results) do
if result.status == "failed" and tree:get_key(pos_id) then
failed = failed + 1
end
end
vim.schedule(function()
local trouble = require("trouble")
if trouble.is_open() then
trouble.refresh()
if failed == 0 then
trouble.close()
end
end
end)
return {}
end
end
end
-- TIP: Add adapters here
table.insert(opts.adapters, require("neotest-vitest"))
if opts.adapters then
local adapters = {}
for name, config in pairs(opts.adapters or {}) do
if type(name) == "number" then
if type(config) == "string" then
config = require(config)
end
adapters[#adapters + 1] = config
elseif config ~= false then
local adapter = require(name)
if type(config) == "table" and not vim.tbl_isempty(config) then
local meta = getmetatable(adapter)
if adapter.setup then
adapter.setup(config)
elseif meta and meta.__call then
adapter(config)
else
error("Adapter " .. name .. " does not support setup")
end
end
adapters[#adapters + 1] = adapter
end
end
opts.adapters = adapters
end
require("neotest").setup(opts)
end,
-- stylua: ignore
keys = {
-- TIP: Shortcuts in test summary window:
-- r: Run the selected test
-- a: Attaches to the test result (output)
-- i: Jumps to the code of the test
{ "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Test: Run File" },
{ "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Test: Run All Test Files" },
{ "<leader>tr", function() require("neotest").run.run() end, desc = "Test: Run Nearest" },
{ "<leader>tl", function() require("neotest").run.run_last() end, desc = "Test: Run Last" },
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Test: Toggle Summary" },
{ "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Test: Show Output" },
{ "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Test: Toggle Output Panel" },
{ "<leader>tS", function() require("neotest").run.stop() end, desc = "Test: Stop" },
},
},
}

View File

@@ -20,16 +20,27 @@ return {
function() function()
require("neo-tree.command").execute({ source = "buffers", toggle = true }) require("neo-tree.command").execute({ source = "buffers", toggle = true })
end, end,
desc = "NeoTree: Open [B]uffer [E]xplorer", desc = "NeoTree: Open [B]buffer [E]xplorer",
}, },
}, },
deactivate = function()
vim.cmd([[Neotree close]])
end,
init = function()
if vim.fn.argc(-1) == 1 then
local stat = vim.loop.fs_stat(vim.fn.argv(0))
if stat and stat.type == "directory" then
require("neo-tree")
end
end
end,
opts = { opts = {
enable_git_status = true, enable_git_status = true,
filesystem = { filesystem = {
bind_to_cwd = true, bind_to_cwd = true,
follow_current_file = { follow_current_file = {
enabled = true, -- Highlight the current buffer enabled = true, -- Highlight the current buffer
leave_dirs_open = true, leave_dirs_open = false,
}, },
use_libuv_file_watcher = true, -- Sync file system changes use_libuv_file_watcher = true, -- Sync file system changes
filtered_items = { filtered_items = {
@@ -43,23 +54,63 @@ return {
position = "left", position = "left",
width = 30, -- Saner window size width = 30, -- Saner window size
mappings = { mappings = {
["s"] = "open_split", -- Default vim keymap for horizontal split ["s"] = "open_split", -- horizontal split
["v"] = "open_vsplit", -- Default vim keymap for vertical split ["v"] = "open_vsplit", -- vertical split
["Y"] = function(state)
local node = state.tree:get_node()
local path = node:get_id()
vim.fn.setreg("+", path, "c")
end,
}, },
}, },
default_component_configs = { default_component_configs = {
indent = { indent = {
indent_size = 2, -- Compact tree display indent_size = 2, -- Compact tree display
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
}, },
}, },
sources = { "filesystem", "buffers", "git_status", "document_symbols" }, sources = { "filesystem", "buffers", "git_status", "document_symbols" },
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
}, },
config = function(_, opts)
local config = require("config.util")
local function on_move(data)
config.on_rename(data.source, data.destination)
end
local events = require("neo-tree.events")
opts.event_handlers = opts.event_handlers or {}
vim.list_extend(opts.event_handlers, {
{ event = events.FILE_MOVED, handler = on_move },
{ event = events.FILE_RENAMED, handler = on_move },
})
require("neo-tree").setup(opts)
vim.api.nvim_create_autocmd("TermClose", {
pattern = "*lazygit",
callback = function()
if package.loaded["neo-tree.sources.git_status"] then
require("neo-tree.sources.git_status").refresh()
end
end,
})
end,
}, },
-- Automatically highlights other instances of the word under cursor -- Automatically highlights other instances of the word under cursor
{ {
"RRethy/vim-illuminate", "RRethy/vim-illuminate",
lazy = false,
opts = {
delay = 200,
large_file_cutoff = 2000,
large_file_override = {
providers = { "lsp" },
},
},
config = function(_, opts) config = function(_, opts)
-- Copied from LazyNvim -- Copied from LazyNvim
require("illuminate").configure(opts) require("illuminate").configure(opts)
@@ -109,8 +160,12 @@ return {
}, },
opts = { opts = {
options = { options = {
close_command = function(n) require("mini.bufremove").delete(n, false) end, close_command = function(n)
right_mouse_command = function(n) require("mini.bufremove").delete(n, false) end, require("mini.bufremove").delete(n, false)
end,
right_mouse_command = function(n)
require("mini.bufremove").delete(n, false)
end,
diagnostics = "nvim_lsp", diagnostics = "nvim_lsp",
always_show_bufferline = false, always_show_bufferline = false,
offsets = { offsets = {
@@ -121,6 +176,9 @@ return {
text_align = "left", text_align = "left",
}, },
}, },
numbers = function(opts)
return string.format("%s", opts.raise(opts.id))
end,
}, },
}, },
config = function(_, opts) config = function(_, opts)
@@ -161,7 +219,7 @@ return {
}, },
opts = { opts = {
render = "wrapped-compact", -- Smaller popups render = "wrapped-compact", -- Smaller popups
timeout = 3000, timeout = 2500,
max_height = function() max_height = function()
return math.floor(vim.o.lines * 0.25) return math.floor(vim.o.lines * 0.25)
end, end,
@@ -184,11 +242,17 @@ return {
}, },
opts = { opts = {
lsp = { lsp = {
progress = {
throttle = 1000 / 100,
},
override = { override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true, ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true, ["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true, ["cmp.entry.get_documentation"] = true,
}, },
hover = {
silent = true,
},
}, },
routes = { routes = {
{ {
@@ -214,11 +278,15 @@ return {
{ find = "yanked" }, { find = "yanked" },
{ find = "fewer lines" }, { find = "fewer lines" },
{ find = "more lines" }, { find = "more lines" },
{ find = "EasyMotion" }, -- This can be completely discarded { find = "EasyMotion" },
{ find = "Target key" }, { find = "Target key" },
{ find = "search hit BOTTOM" }, { find = "search hit BOTTOM" },
{ find = "lines to indent" }, { find = "lines to indent" },
{ find = "lines indented" }, { find = "lines indented" },
{ find = "lines changed" },
{ find = ">ed" },
{ find = "<ed" },
{ find = "The only match" },
}, },
}, },
}, },
@@ -233,15 +301,6 @@ return {
}, },
keys = { keys = {
{ "<leader>nx", "<cmd>NoiceDismiss<CR>", desc = "Dismiss all [N]oice notifications" }, { "<leader>nx", "<cmd>NoiceDismiss<CR>", desc = "Dismiss all [N]oice notifications" },
-- TODO: Find better keymaps
-- { "<S-Enter>", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" },
-- { "<leader>snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" },
-- { "<leader>snh", function() require("noice").cmd("history") end, desc = "Noice History" },
-- { "<leader>sna", function() require("noice").cmd("all") end, desc = "Noice All" },
-- { "<leader>snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" },
-- { "<leader>snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" },
-- { "<c-f>", function() if not require("noice.lsp").scroll(4) then return "<c-f>" end end, silent = true, expr = true, desc = "Scroll forward", mode = { "i", "n", "s" } },
-- { "<c-b>", function() if not require("noice.lsp").scroll(-4) then return "<c-b>" end end, silent = true, expr = true, desc = "Scroll backward", mode = { "i", "n", "s" } },
}, },
}, },
@@ -249,16 +308,123 @@ return {
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
-- See `:help lualine.txt` -- See `:help lualine.txt`
opts = { --
-- TODO: Need the following: init = function()
-- - Remove encoding & OS vim.g.lualine_laststatus = vim.o.laststatus
-- - Add Breadcrumb if vim.fn.argc(-1) > 0 then
-- - Show command that was typed -- set an empty statusline till lualine loads
vim.o.statusline = " "
else
-- hide the statusline on the starter page
vim.o.laststatus = 0
end
end,
opts = function()
local lualine_require = require("lualine_require")
lualine_require.require = require
vim.o.laststatus = vim.g.lualine_laststatus
local config = require("config.util")
return {
options = { options = {
icons_enabled = false, theme = "auto",
icons_enabled = true,
globalstatus = true,
component_separators = "|", component_separators = "|",
section_separators = "", section_separators = "",
}, },
extensions = { "neo-tree", "lazy" },
sections = {
lualine_a = { "mode" },
lualine_b = { "branch" },
lualine_c = {
{
"diagnostics",
symbols = {
error = config.icons.diagnostics.Error,
warn = config.icons.diagnostics.Warn,
info = config.icons.diagnostics.Info,
hint = config.icons.diagnostics.Hint,
},
},
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{
"filename",
file_status = true,
path = 1,
},
-- Breadcrumbs from "nvim-navic" plugin
{
function()
return require("nvim-navic").get_location()
end,
cond = function()
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
end,
},
},
lualine_x = {
{
function()
return require("noice").api.status.command.get()
end,
cond = function()
return package.loaded["noice"] and require("noice").api.status.command.has()
end,
color = config.fg("Statement"),
},
{
function()
return require("noice").api.status.mode.get()
end,
cond = function()
return package.loaded["noice"] and require("noice").api.status.mode.has()
end,
color = config.fg("Constant"),
},
{
function()
return "" .. require("dap").status()
end,
cond = function()
return package.loaded["dap"] and require("dap").status() ~= ""
end,
color = config.fg("Debug"),
},
{
"diff",
symbols = {
added = config.icons.git.added,
modified = config.icons.git.modified,
removed = config.icons.git.removed,
},
source = function()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end,
},
},
lualine_y = {
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
{ "location", padding = { left = 0, right = 1 } },
},
lualine_z = {
function()
return "" .. os.date("%R")
end,
}, },
}, },
} }
end,
},
}

View File

@@ -52,14 +52,10 @@ return {
-- Load some required Telescope extensions -- Load some required Telescope extensions
pcall(require("telescope").load_extension, "fzf") pcall(require("telescope").load_extension, "fzf")
pcall(require("telescope").load_extension, "noice")
pcall(require("telescope").load_extension, "undo")
-- Special Things: [T]elescope -- Special Things: [T]elescope
vim.keymap.set("n", "<leader>tr", require("telescope.builtin").resume, vim.keymap.set("n", "<leader>nc", require("telescope.builtin").colorscheme,
{ desc = "[T]elescope [R]esume Last Search" }) { desc = "List [N]eovim [C]olorschemes (with preview)" })
vim.keymap.set("n", "<leader>tc", require("telescope.builtin").colorscheme,
{ desc = "List Colorschemes (with preview)" })
-- Grep things -> [S]earch -- Grep things -> [S]earch
vim.keymap.set("n", "<leader>sb", function() vim.keymap.set("n", "<leader>sb", function()
@@ -83,8 +79,7 @@ return {
{ desc = "[L]ist & Search NeoVIM [H]elp" }) { desc = "[L]ist & Search NeoVIM [H]elp" })
vim.keymap.set("n", "<leader>lk", require("telescope.builtin").keymaps, vim.keymap.set("n", "<leader>lk", require("telescope.builtin").keymaps,
{ desc = "[L]ist & Search NeoVIM [K]eymaps" }) { desc = "[L]ist & Search NeoVIM [K]eymaps" })
vim.keymap.set("n", "<leader>lm", require("telescope.builtin").marks, { desc = "[L]ist [M]arks" }) vim.keymap.set("n", "<leader>lm", require("telescope.builtin").man_pages,
vim.keymap.set("n", "<leader>ln", require("telescope.builtin").man_pages,
{ desc = "[L]ist & Search System Ma[n] Pages" }) { desc = "[L]ist & Search System Ma[n] Pages" })
vim.keymap.set("n", "<leader>lq", require("telescope.builtin").quickfixhistory, vim.keymap.set("n", "<leader>lq", require("telescope.builtin").quickfixhistory,
{ desc = "[L]ist [Q]uickfix History" }) { desc = "[L]ist [Q]uickfix History" })
@@ -106,14 +101,24 @@ return {
require("telescope.builtin").lsp_implementations, require("telescope.builtin").lsp_implementations,
{ desc = "[C]ode: Goto [I]mplementation of the word under cursor" } { desc = "[C]ode: Goto [I]mplementation of the word under cursor" }
) )
vim.keymap.set("n", "<leader>cr", require("telescope.builtin").lsp_references, vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references,
{ desc = "[C]ode: List [R]eferences for word under cursor" }) { desc = "[C]ode: List [R]eferences for word under cursor" })
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>ct", "<leader>cgt",
require("telescope.builtin").lsp_type_definitions, require("telescope.builtin").lsp_type_definitions,
{ desc = "[C]ode: Goto definition of the [T]ype under cursor" } { desc = "[C]ode: Goto definition of the [T]ype under cursor" }
) )
vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, { desc = "[G]oto [D]efinition" })
vim.keymap.set("n", "<leader>cgd", require("telescope.builtin").lsp_type_definitions,
{ desc = "Type [D]efinition" })
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references,
{ desc = "[G]oto [R]eferences" })
vim.keymap.set("n", "<leader>cI", require("telescope.builtin").lsp_implementations,
{ desc = "[G]oto [I]mplementation" })
vim.keymap.set("n", "<leader>cs", require("telescope.builtin").lsp_document_symbols,
{ desc = "[D]ocument [S]ymbols" })
-- vim.keymap.set("n", "<leader>cgD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" })
end, end,
}, },
} }

View File

@@ -53,6 +53,7 @@ return {
ensure_installed = { ensure_installed = {
-- These 2 are required for cmdline -- These 2 are required for cmdline
"regex", "regex",
"markdown",
"markdown_inline", "markdown_inline",
}, },
@@ -117,8 +118,8 @@ return {
floating_preview_opts = {}, floating_preview_opts = {},
peek_definition_code = { peek_definition_code = {
-- TIP: Press the shortcut 2 times to enter the floating window -- TIP: Press the shortcut 2 times to enter the floating window
["<leader>df"] = { query = "@function.outer", desc = "Peek function definition on a popup" }, ["<leader>cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
["<leader>dF"] = { query = "@class.outer", desc = "Peek class definition on a popup" }, ["<leader>cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
}, },
}, },
}, },

View File

@@ -2,13 +2,19 @@ return {
-- Navigate between NVIM & Tmux splits seamlessly -- Navigate between NVIM & Tmux splits seamlessly
{ "christoomey/vim-tmux-navigator" }, { "christoomey/vim-tmux-navigator" },
-- Navigate between NVIM & kitty splits seamlessly
{
"knubie/vim-kitty-navigator",
build = "cp ./*.py ~/.config/kitty/",
},
-- Open Kitty terminal scrollback as buffer -- Open Kitty terminal scrollback as buffer
{ {
"mikesmithgh/kitty-scrollback.nvim", "mikesmithgh/kitty-scrollback.nvim",
lazy = true, lazy = true,
cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" }, cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
event = { "User KittyScrollbackLaunch" }, event = { "User KittyScrollbackLaunch" },
version = "^3.0.0", version = "^4.0.0",
opts = { opts = {
status_window = { status_window = {
icons = { nvim = "" }, icons = { nvim = "" },
@@ -26,13 +32,9 @@ return {
require("which-key").register({ require("which-key").register({
["<leader>e"] = { name = "[E]xplorer", _ = "which_key_ignore" }, ["<leader>e"] = { name = "[E]xplorer", _ = "which_key_ignore" },
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" }, ["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" }, ["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
["<leader>h"] = { name = "Git [H]unk", _ = "which_key_ignore" },
["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" }, ["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" }, ["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" },
["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
}) })
-- register which-key VISUAL mode -- register which-key VISUAL mode
-- required for visual <leader>hs (hunk stage) to work -- required for visual <leader>hs (hunk stage) to work
@@ -43,20 +45,46 @@ return {
end, end,
}, },
-- Session management. This saves your session in the background, -- Session management. Saves your session in the background
-- keeping track of open buffers, window arrangement, and more.
-- You can restore sessions when returning through the dashboard.
{ {
-- TODO:
-- 1. Find out where they are stored exactly.
-- 2. Add them to source control
-- 3. Need a startup dashboard with options for loading last session
"folke/persistence.nvim", "folke/persistence.nvim",
event = "BufReadPre", event = "BufReadPre",
opts = { options = vim.opt.sessionoptions:get() }, opts = {
-- Session files stored at: ~/.config/nvim/sessions/
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"),
options = vim.opt.sessionoptions:get()
-- NOTE: autocmd to autoload sessions at: ../config/autocmd.lua
},
keys = { keys = {
{ "<leader>sr", function() require("persistence").load() end, desc = "[R]estore [S]ession" }, -- Since we are auto-restoring sessions, keymaps aren't required
{ "<leader>sl", function() require("persistence").load({ last = true }) end, desc = "[R]estore [L]ast Session" }, -- { "<leader>sr", function() require("persistence").load() end, desc = "[R]estore [S]ession" },
-- { "<leader>sl", function() require("persistence").load({ last = true }) end, desc = "[R]estore [L]ast Session" },
},
},
-- Speedup loading large files by disabling some plugins
{
"LunarVim/bigfile.nvim",
lazy = true,
opts = {
filesize = 2, --2MiB
pattern = "*",
features = {
"indent_blankline",
"lsp",
"syntax",
"treesitter",
},
},
},
-- Provides tldr on vertical split
-- `:Tldr [command]`
{
"wlemuel/vim-tldr",
lazy = true,
dependencies = {
"nvim-telescope/telescope.nvim"
}, },
}, },
} }

View File

@@ -1,100 +0,0 @@
#!/bin/sh
# Generic
alias bashreload="source ~/.bashrc"
alias zshreload="source ~/.zshrc"
alias free="free -ht"
alias type="type -a"
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias usersearch="awk -F: '{print \"UserName: \" \$1 \", UserID: \" \$3 \", Home Dir: \" \$6 \", Shell Used: \" \$7}' /etc/passwd | grep"
alias untar='tar -zxvf '
alias wget="wget --hsts-file ${WGET_HSTS_FILE}"
alias v="${EDITOR}"
alias snvim="${HOMEBREW_PREFIX}/bin/nvim" # Stable nvim
url_encode(){
python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.stdin.read()))" <<< "$1"
}
# History
alias histsearch="history | grep"
alias hs="histsearch"
alias hsi="histsearch"
# Directories and Directory listings
alias ~="cd ~"
alias ..="cd .."
alias ...='cd ../../../' # Go back 3 directory levels
alias cd_root='cd $(git rev-parse --show-toplevel 2>/dev/null || echo ".")'
alias cd_git_root=cd_root
alias cl=clear
alias lsc='ls --color=auto --hyperlink=auto'
alias ll='lsc -alhF'
alias la='lsc -Ah'
alias l='lsc -CF'
alias lsa="lsc -lAFhZ"
alias mkdir="mkdir -pv"
alias df="df -h"
mkcd () {
mkdir "$1"
cd "$1" || exit
}
# Network
alias ping="ping -c 10"
alias ping8="ping 8.8.8.8"
alias ping1="ping 1.1.1.1"
alias p8="ping8"
alias p1="ping1"
alias pubip="curl https://ipinfo.io/ip; echo"
alias speedtest="speedtest-cli --secure"
geoip () {
curl -s https://ipinfo.io | sed '/readme\|loc\|postal\|{\|}\|hostname/d;s/org/ISP/;s/"\|,$//g' | awk -F ':' 'NF { printf("%10s: %s \n", $1, $2)}'
}
# Git
git_push_all_changes(){
git add . && git commit -am "${1}" && git push
}
alias git_just_push=git_push_all_changes
alias ta="tmux a"
alias tat="tmux a -t"
alias tls="tmux ls"
alias tnew="tmux new"
alias tnewt="tmux new -t"
# Nvim Distro-Switcher
alias nvim-lazy="NVIM_APPNAME=nvim-lazy nvim"
alias OldConfig="NVIM_APPNAME=oldconfig nvim"
nvims() {
items=$(find -L "$HOME"/.config -maxdepth 2 -name "init.lua" -type f -execdir sh -c 'pwd | xargs basename' \;)
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config  " --height=~50% --layout=reverse --border --exit-0)
if [ -z "$config" ]; then
echo "Nothing selected"
return 0
elif [ "$config" = "default" ]; then
config=""
fi
NVIM_APPNAME=$config nvim "$@"
}
op() {
local chosen_project
chosen_project="$(find -L ~/Code -mindepth 2 -maxdepth 2 -not -path '*/.*' -printf "%T@ %p\n" | sort -nr | cut -d ' ' -f 2- | fzf --border --layout=reverse --height=~50% --prompt='Select a project: ' --preview 'ls -Lltc {1}')"
if [ -z "$chosen_project" ]; then
return 0
fi
cd "$chosen_project" || return
nvim
}
# TODO: Create fuzzy finder for cht.sh & tldr

View File

@@ -0,0 +1,47 @@
#!/bin/sh
# Generic
alias bashreload="source ~/.bashrc"
alias zshreload="source ~/.zshrc"
alias free="free -ht"
alias type="type -a"
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias usersearch="awk -F: '{print \"UserName: \" \$1 \", UserID: \" \$3 \", Home Dir: \" \$6 \", Shell Used: \" \$7}' /etc/passwd | grep"
alias untar='tar -zxvf '
alias wget="wget --hsts-file ${WGET_HSTS_FILE}"
alias v="${EDITOR}"
alias snvim="${HOMEBREW_PREFIX}/bin/nvim" # Stable nvim
# Directories and Directory listings
alias ~="cd ~"
alias ..="cd .."
alias ...='cd ../../../' # Go back 3 directory levels
alias cl=clear
alias lsc='ls --color=auto --hyperlink'
alias ll='lsc -alhF'
alias la='lsc -Ah'
alias lsa="lsc -lAFhZ"
alias mkdir="mkdir -pv"
alias df="df -h"
mkcd () {
mkdir "$1"
cd "$1" || exit
}
# Network
alias ping="ping -c 10"
alias ping8="ping 8.8.8.8"
alias ping1="ping 1.1.1.1"
alias p8="ping8"
alias p1="ping1"
alias pubip="curl https://ipinfo.io/ip; echo"
alias speedtest="speedtest-cli --secure"
geoip () {
curl -s https://ipinfo.io | sed '/readme\|loc\|postal\|{\|}\|hostname/d;s/org/ISP/;s/"\|,$//g' | awk -F ':' 'NF { printf("%10s: %s \n", $1, $2)}'
}

View File

@@ -788,7 +788,7 @@
# #
# These variables correspond to the last line of the output of `todo.sh -p ls`: # These variables correspond to the last line of the output of `todo.sh -p ls`:
# #
# TODO: 24 of 42 tasks shown # todo: 24 of 42 tasks shown
# #
# Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT.
# #

View File

@@ -1,14 +1,37 @@
[user] [user]
email = mail@pratik.live email = mail@pratik.live
name = Pratik Tripathy name = Pratik Tripathy
[core] [core]
autocrlf = input autocrlf = input
editor = code --wait editor = nvim
excludesfile = ~/.gitignore
# Make `git rebase` safer on macOS
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
trustctime = false
[diff] [diff]
tool = vscode tool = vscode
[difftool "vscode"] [difftool "vscode"]
cmd = "code --wait --diff $LOCAL $REMOTE" cmd = "code --wait --diff $LOCAL $REMOTE"
[merge]
tool = vscode
conflictstyle = diff3
[mergetool]
prompt = true
keepBackup = false
[mergetool "vscode"]
cmd = code --wait $MERGED
[log]
date = relative
[alias] [alias]
ll = log --pretty=format:'%Cblue%cn (%ce)%Creset commited %Cred%h%Creset %Cgreen%cr%Creset:%n%B' ll = log --pretty=format:'%Cblue%cn (%ce)%Creset commited %Cred%h%Creset %Cgreen%cr%Creset:%n%B'
unstage = restore --staged . unstage = restore --staged .
cleanup = "!git remote prune origin && git gc && git clean -df && git stash clear"

3
common/.gitignore vendored
View File

@@ -97,6 +97,3 @@ lerna-debug.log*
**/contents/images **/contents/images
**/contents/fonts **/contents/fonts
*kpluginindex.json *kpluginindex.json
*.bak
nvim_switch/

View File

@@ -34,12 +34,6 @@ export VISUAL=$EDITOR
# Manually follow steps from https://steamcommunity.com/app/646570/discussions/1/3935537639868400686 # Manually follow steps from https://steamcommunity.com/app/646570/discussions/1/3935537639868400686
# To disable ~/.oracle_jre_usage/ from being created # To disable ~/.oracle_jre_usage/ from being created
# Source aliases
[ ! -f "$XDG_CONFIG_HOME/shell/aliases" ] || source "$XDG_CONFIG_HOME/shell/aliases"
[ ! -f "$XDG_CONFIG_HOME/shell/aliases_mac" ] || source "$XDG_CONFIG_HOME/shell/aliases_mac"
[ ! -f "$XDG_CONFIG_HOME/shell/aliases_neon" ] || source "$XDG_CONFIG_HOME/shell/aliases_neon"
[ ! -f "$XDG_CONFIG_HOME/shell/aliases_personal" ] || source "$XDG_CONFIG_HOME/shell/aliases_personal"
if [ "$(uname -s)" = "Linux" ]; then if [ "$(uname -s)" = "Linux" ]; then
export __GL_SHADER_DISK_CACHE_PATH="$XDG_CACHE_HOME/nvidia" export __GL_SHADER_DISK_CACHE_PATH="$XDG_CACHE_HOME/nvidia"

View File

@@ -0,0 +1,7 @@
" Enable spell check for markdown, gitcommit & text files
augroup spell_check_text_files
autocmd!
autocmd FileType markdown setlocal spell
autocmd FileType gitcommit setlocal spell
autocmd FileType text setlocal spell
augroup END

View File

@@ -23,7 +23,7 @@ set viewoptions-=options
set nolangremap " Do not use non-English keyboards to define keymaps set nolangremap " Do not use non-English keyboards to define keymaps
set list " Show tabs as >, trailing spaces as -, non-breakable space as + set list " Show tabs as >, trailing spaces as -, non-breakable space as +
set signcolumn=yes " Always show the signs column (before line number column) set signcolumn=yes " Always show the signs column (before line number column)
set scrolloff=5 " Cursor always at middle of the screen set scrolloff=10 " Cursor always at middle of the screen
set updatetime=249 " No typing for this millisec -> write to swap file set updatetime=249 " No typing for this millisec -> write to swap file
set timeoutlen=500 " Multiple keys in keymaps must be pressed in these millisecs set timeoutlen=500 " Multiple keys in keymaps must be pressed in these millisecs
set noswapfile " Turn off swapfiles set noswapfile " Turn off swapfiles
@@ -64,11 +64,7 @@ autocmd BufWritePre * %s/\s\+$//e
set backspace=indent,eol,start set backspace=indent,eol,start
" Sync vim clipboard with system clipboard. Works across Linux, MacOS & Windows. " Sync vim clipboard with system clipboard. Works across Linux, MacOS & Windows.
if has("mac") set clipboard^=unnamed
set clipboard+=unnamed
else
set clipboard^=unnamed,unnamedplus
endif
" Set color " Set color
if !has('gui_running') if !has('gui_running')

View File

@@ -62,6 +62,10 @@ map <C-l> <C-w>l
nnoremap <Tab> :bnext<CR> nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR> nnoremap <S-Tab> :bprevious<CR>
" Navigate Quickfixs
nnoremap [q cprev
nnoremap ]q cnext
" Resize window using <ctrl> arrow keys " Resize window using <ctrl> arrow keys
nnoremap <C-Up> :resize +2<CR> nnoremap <C-Up> :resize +2<CR>
nnoremap <C-Down> :resize -2<CR> nnoremap <C-Down> :resize -2<CR>
@@ -83,16 +87,29 @@ nnoremap <C-s> :wa<CR>
vnoremap <C-s> :wa<CR> vnoremap <C-s> :wa<CR>
" Move cursor in insert mode " Move cursor in insert mode
inoremap <M-b> <ESC>^i inoremap <M-a> <ESC>^i
inoremap <M-e> <END> inoremap <M-e> <END>
inoremap <M-h> <Left> inoremap <M-h> <Left>
inoremap <M-l> <Right> inoremap <M-l> <Right>
inoremap <M-j> <Down> inoremap <M-j> <Down>
inoremap <M-k> <Up> inoremap <M-k> <Up>
" Ctrl+Backspace to add an undo-point and delete last word
imap <C-BS> <C-W><C-g>u
" Insert mode: add undo points on "," & "." & ";"
imap , ,<C-g>u
imap . .<C-g>u
imap ; ;<C-g>u
" Copy entire content of the current buffer " Copy entire content of the current buffer
nnoremap <C-c> :%y+<CR> nnoremap <C-c> :%y+<CR>
" Copy to system clipboard
nnoremap <leader>y "+y
vnoremap <leader>y "+y
" To paste from system clipboard "+p
" Clear search, diff update and redraw " Clear search, diff update and redraw
nnoremap <leader>/ :nohlsearch<CR>:diffupdate<CR>:normal! <C-L><CR> nnoremap <leader>/ :nohlsearch<CR>:diffupdate<CR>:normal! <C-L><CR>
@@ -104,4 +121,3 @@ nnoremap <leader>j <Plug>(easymotion-s)
" Show the undo tree " Show the undo tree
nnoremap <leader>u :UndotreeToggle<CR> nnoremap <leader>u :UndotreeToggle<CR>

View File

@@ -10,6 +10,9 @@ source $VIMDIR/configs.vim
" Load Keybindings " Load Keybindings
source $VIMDIR/key_maps.vim source $VIMDIR/key_maps.vim
" Load Autocommand
source $VIMDIR/autocommands.vim
" Save session files to $HOME/.vim/session directory " Save session files to $HOME/.vim/session directory
let g:session_dir="$VIMDIR/session" let g:session_dir="$VIMDIR/session"

View File

@@ -47,14 +47,9 @@ HIST_STAMPS="dd.mm.yyyy"
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Custom plugins may be added to $ZSH_CUSTOM/plugins/
plugins=( plugins=(
git git
# dotenv
# dotnet
gitignore gitignore
# colored-man-pages
docker docker
# fd
per-directory-history per-directory-history
# ripgrep
sudo sudo
zsh-syntax-highlighting zsh-syntax-highlighting
zsh-autosuggestions zsh-autosuggestions
@@ -93,6 +88,7 @@ bindkey -v
# Add brew provided autocompletions to path # Add brew provided autocompletions to path
[[ ! -d "/home/linuxbrew/.linuxbrew/share/zsh/site-functions" ]] || FPATH="/home/linuxbrew/.linuxbrew/share/zsh/site-functions:$FPATH" [[ ! -d "/home/linuxbrew/.linuxbrew/share/zsh/site-functions" ]] || FPATH="/home/linuxbrew/.linuxbrew/share/zsh/site-functions:$FPATH"
# Auto/tab completions # Auto/tab completions
autoload -Uz compinit autoload -Uz compinit
zstyle ':completion::complete:*' gain-privileges 1 menu select cache-path "$XDG_CACHE_HOME/zsh/zcompcache" zstyle ':completion::complete:*' gain-privileges 1 menu select cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
@@ -105,5 +101,11 @@ _comp_options+=(globdots) # Include hidden files
# [alt+c] :fzf & cd into a directory under the current one # [alt+c] :fzf & cd into a directory under the current one
[ -f "$XDG_STATE_HOME/shell/fzf.zsh" ] && source "$XDG_STATE_HOME/shell/fzf.zsh" [ -f "$XDG_STATE_HOME/shell/fzf.zsh" ] && source "$XDG_STATE_HOME/shell/fzf.zsh"
command -v zoxide >/dev/null && eval "$(zoxide init zsh)" command -v zoxide >/dev/null && eval "$(zoxide init --cmd cd zsh)"
command -v zoxide >/dev/null && bindkey -s '^o' 'op\n' # Fuzzyfind projects and open in nvim
# Source aliases and shell functions
for alias_file in "$XDG_CONFIG_HOME"/shell/*.sh; do source "$alias_file"; done
# TIP: Following should be executed AFTER the aliases are sourced
command -v op >/dev/null && bindkey -s '^o' 'op\n' # Fuzzyfind projects and open in nvim
command -v pnew >/dev/null && bindkey -s '^[o' 'pnew\n' # Create a new project quickly