improve terminal buffers
This commit is contained in:
parent
ad7c791d23
commit
9be8d154ca
109
config/linux-dev/nvim/docs/commands.md
Normal file
109
config/linux-dev/nvim/docs/commands.md
Normal file
@ -0,0 +1,109 @@
|
||||
#============================================================
|
||||
# Neovim Command Reference (Core Commands)
|
||||
#============================================================
|
||||
|
||||
|
||||
#============================================================
|
||||
# FILE & SESSION MANAGEMENT
|
||||
#============================================================
|
||||
:w (write) Save current buffer
|
||||
:w <file> Write to <file> (does NOT rename buffer)
|
||||
:sav (saveas) <file> Save to <file> and rename current buffer
|
||||
:q (quit) Quit current window if no unsaved changes
|
||||
:q! Force quit (discard changes)
|
||||
:wq Write and quit current buffer
|
||||
:wqa Write and quit all buffers
|
||||
:qa Quit all windows
|
||||
:qa! Quit all without saving
|
||||
:e (edit) <file> Edit <file> in current window (new buffer)
|
||||
:e! Revert buffer to last saved version (discard changes)
|
||||
:enew Create new empty buffer
|
||||
:r (read) <file> Read <file> into current buffer after cursor
|
||||
:ter (terminal) Open terminal buffer
|
||||
:clo (close) Close current window
|
||||
|
||||
|
||||
#============================================================
|
||||
# BUFFERS
|
||||
#============================================================
|
||||
:ls (buffers) List open buffers
|
||||
:bn (bnext) Go to next buffer
|
||||
:bp (bprev) Go to previous buffer
|
||||
:b<num> Go to buffer by number
|
||||
:b <file> Go to buffer by (partial) name
|
||||
:bd (bdelete) [<num>] Delete current (or given) buffer
|
||||
:bw (bwipeout) [<num>] Delete buffer and remove from memory
|
||||
:bo (only) Close all windows except current
|
||||
:e # Edit alternate (previous) buffer
|
||||
:b# Switch to alternate buffer
|
||||
:b% Re-edit current buffer (no-op)
|
||||
:b$ Go to last buffer
|
||||
|
||||
|
||||
#============================================================
|
||||
# WINDOWS (SPLITS)
|
||||
#============================================================
|
||||
:sp (split) [<file>] Split horizontally (optionally open <file>)
|
||||
:vsp (vsplit) [<file>] Split vertically (optionally open <file>)
|
||||
:new Split with new empty buffer
|
||||
:vnew Vertical split with new empty buffer
|
||||
:close Close current window
|
||||
:only Keep only current window open
|
||||
|
||||
|
||||
#============================================================
|
||||
# TABS
|
||||
#============================================================
|
||||
:tabnew [<file>] Open new tab (optionally edit <file>)
|
||||
:tabn (tabnext) Go to next tab
|
||||
:tabp (tabprev) Go to previous tab
|
||||
:tabm (tabmove) <num> Move current tab to position <num>
|
||||
:tabfirst Jump to first tab
|
||||
:tablast Jump to last tab
|
||||
:tabc (tabclose) Close current tab
|
||||
:tabo (tabonly) Close all other tabs
|
||||
:tabdo <cmd> Execute <cmd> in all tabs (e.g. :tabdo q)
|
||||
|
||||
|
||||
#============================================================
|
||||
# REGISTERS, MARKS & HISTORY
|
||||
#============================================================
|
||||
:reg (registers) Show register contents
|
||||
:marks Show all marks
|
||||
:ju (jumps) Show jump list
|
||||
:changes Show change list
|
||||
|
||||
|
||||
#============================================================
|
||||
# SEARCH / GREP / QUICKFIX
|
||||
#============================================================
|
||||
:g/{pattern}/d Delete all lines matching {pattern}
|
||||
:g!/{pattern}/d Delete all lines NOT matching {pattern}
|
||||
:vim /{pattern}/ **/* Search for {pattern} recursively in all files
|
||||
:cn (cnext) Jump to next quickfix entry
|
||||
:cp (cprevious) Jump to previous quickfix entry
|
||||
:cope (copen) Open quickfix window
|
||||
:ccl (cclose) Close quickfix window
|
||||
:cl (clist) List quickfix entries
|
||||
|
||||
|
||||
#============================================================
|
||||
# DIFF MODE
|
||||
#============================================================
|
||||
:diffthis Start diff mode for current window
|
||||
:diffo (diffoff) Turn off diff mode
|
||||
:diffu (diffupdate) Recalculate diff
|
||||
:diffg (diffget) Get changes from other window
|
||||
:diffpu (diffput) Send changes to other window
|
||||
|
||||
|
||||
#============================================================
|
||||
# NOTES & SYMBOLS
|
||||
#============================================================
|
||||
% Current buffer
|
||||
# Alternate (last visited) buffer
|
||||
$ Last buffer in list
|
||||
+ Next buffer
|
||||
- Previous buffer
|
||||
" Most recently edited buffer (context dependent)
|
||||
|
||||
@ -42,6 +42,7 @@ TODO:
|
||||
- lazygit Terminal UI for git commands. (optional)
|
||||
|
||||
- fzf Command-line fuzzy finder.
|
||||
- bat "cat" but with colors
|
||||
- curl Command-line for transferring data specified with URL syntax.
|
||||
- wget Utility for downloading files from the Web.
|
||||
- make
|
||||
@ -132,6 +133,7 @@ TODO:
|
||||
- markdown-preview.nvim side by side md (disabled in folke)
|
||||
- toppair/peek.nvim another markdown preview?
|
||||
- render-markdown.nvim inline viewer
|
||||
- markview.nvim
|
||||
- diffview.nvim
|
||||
- octo.nvim edit and review GH issues and pr
|
||||
- yanky.nvim better yank+put. has history
|
||||
|
||||
119
config/linux-dev/nvim/docs/keymaps.md
Normal file
119
config/linux-dev/nvim/docs/keymaps.md
Normal file
@ -0,0 +1,119 @@
|
||||
#============================================================
|
||||
# NEOVIM KEYMAP REFERENCE (CORE & USEFUL)
|
||||
#============================================================
|
||||
|
||||
|
||||
#============================================================
|
||||
# INSERT MODE (Ctrl + ...)
|
||||
#============================================================
|
||||
Ctrl + h Delete character before cursor
|
||||
Ctrl + w Delete word before cursor
|
||||
Ctrl + j Insert line break (newline) at cursor
|
||||
Ctrl + t Indent current line one 'shiftwidth' to the right
|
||||
Ctrl + d De-indent current line one 'shiftwidth' to the left
|
||||
Ctrl + n Insert next auto-completion match
|
||||
Ctrl + p Insert previous auto-completion match
|
||||
Ctrl + r x Insert contents of register x
|
||||
Ctrl + o {cmd} Temporarily enter Normal mode to execute {cmd}
|
||||
Esc / Ctrl + c Exit insert mode and return to Normal mode
|
||||
|
||||
|
||||
#============================================================
|
||||
# NORMAL MODE — WINDOW & TAB MANAGEMENT
|
||||
#============================================================
|
||||
C-w s Split current window horizontally
|
||||
C-w v Split current window vertically
|
||||
C-w c Close current window
|
||||
C-w q Quit current window (same as close but exit if last)
|
||||
C-w w Cycle through open windows
|
||||
C-w x Exchange window with next one
|
||||
|
||||
C-w = Equalize window sizes
|
||||
C-w _ Maximize height of current window
|
||||
C-w | Maximize width of current window
|
||||
|
||||
C-w h Move to window left
|
||||
C-w j Move to window below
|
||||
C-w k Move to window above
|
||||
C-w l Move to window right
|
||||
|
||||
C-w H Move current window far left
|
||||
C-w J Move current window to bottom
|
||||
C-w K Move current window to top
|
||||
C-w L Move current window far right
|
||||
|
||||
C-w t Move current split into a new tab
|
||||
|
||||
gt Go to next tab
|
||||
gT Go to previous tab
|
||||
<n>gt Go to tab number <n>
|
||||
|
||||
|
||||
#============================================================
|
||||
# NORMAL MODE — TAGS, JUMPS & MOTIONS
|
||||
#============================================================
|
||||
Ctrl + ] Jump to tag under cursor
|
||||
gd Go to local declaration
|
||||
gD Go to global declaration
|
||||
{ Jump backward one paragraph/block
|
||||
} Jump forward one paragraph/block
|
||||
; Repeat last motion forward
|
||||
, Repeat last motion backward
|
||||
Ctrl + e Scroll window down (cursor stays put)
|
||||
Ctrl + y Scroll window up (cursor stays put)
|
||||
H Move cursor to top of screen
|
||||
M Move cursor to middle of screen
|
||||
L Move cursor to bottom of screen
|
||||
|
||||
|
||||
#============================================================
|
||||
# NORMAL MODE — TEXT OBJECTS
|
||||
#============================================================
|
||||
aw "A word" — select word + following space
|
||||
ab "A block" — select around ()
|
||||
aB "A Block" — select around {}
|
||||
at "A tag" — select around XML/HTML tag
|
||||
|
||||
ib "Inner block" — inside ()
|
||||
iB "Inner Block" — inside {}
|
||||
it "Inner tag" — inside tag (no delimiters)
|
||||
|
||||
|
||||
#============================================================
|
||||
# NORMAL MODE — DIFF / CHANGES
|
||||
#============================================================
|
||||
do Obtain (get) changes from other window
|
||||
dp Put (send) changes to other window
|
||||
|
||||
|
||||
#============================================================
|
||||
# REGISTERS & CLIPBOARD
|
||||
#============================================================
|
||||
"xy Yank into register x
|
||||
"xp Paste contents of register x
|
||||
"+y Yank into system clipboard
|
||||
"+p Paste from system clipboard
|
||||
|
||||
#--- Common Registers ---
|
||||
"0 Last yank
|
||||
" Unnamed register (last delete or yank)
|
||||
"% Current file name
|
||||
"# Alternate file name
|
||||
"* X11 primary selection clipboard
|
||||
"+ X11 clipboard register
|
||||
"/ Last search pattern
|
||||
": Last command-line command
|
||||
". Last inserted text
|
||||
"- Last small (less than a line) delete
|
||||
"= Expression register (evaluate expression)
|
||||
"_ Black hole register (discard output)
|
||||
|
||||
|
||||
#============================================================
|
||||
# TIPS & NOTES
|
||||
#============================================================
|
||||
- Ctrl + o in Insert mode is a powerful way to run one Normal-mode command temporarily.
|
||||
- Use “aw”, “iw”, “ab”, “ib”, etc. with operators (e.g., ‘daw’, ‘yib’) for precise text manipulation.
|
||||
- The system clipboard is “+” (Windows/macOS/Linux), but some X11 systems also use “*”.
|
||||
- When in diff mode, ‘do’ and ‘dp’ are complementary: “get” vs. “put” changes.
|
||||
|
||||
@ -6,78 +6,67 @@ Ctrl-w c - Close current window
|
||||
Ctrl-w o - Close all windows except current one
|
||||
|
||||
-- Window Navigation
|
||||
Ctrl-w h - Move to window on the left
|
||||
Ctrl-w j - Move to window below
|
||||
Ctrl-w k - Move to window above
|
||||
Ctrl-w l - Move to window on the right
|
||||
Ctrl-h - Move to window on the left
|
||||
Ctrl-j - Move to window below
|
||||
Ctrl-k - Move to window above
|
||||
Ctrl-l - Move to window on the right
|
||||
|
||||
-- Window Moving/Rearranging
|
||||
Ctrl-w H - Move current window to far left
|
||||
Ctrl-w J - Move current window to bottom
|
||||
Ctrl-w K - Move current window to top
|
||||
Ctrl-w L - Move current window to far right
|
||||
Ctrl-w r - Rotate windows downward/rightward
|
||||
Ctrl-w R - Rotate windows upward/leftward
|
||||
Ctrl-w x - Exchange current window with next one
|
||||
|
||||
-- Window Resizing
|
||||
Ctrl-w = - Make all windows equal size
|
||||
Ctrl-w _ - Maximize height of current window
|
||||
Ctrl-w | - Maximize width of current window
|
||||
Ctrl-w > - Increase width by 1 column
|
||||
Ctrl-w < - Decrease width by 1 column
|
||||
Ctrl-w + - Increase height by 1 row
|
||||
Ctrl-w - - Decrease height by 1 row
|
||||
Ctrl-w > - Increase width by 5 column
|
||||
Ctrl-w < - Decrease width by 5 column
|
||||
Ctrl-w + - Increase height by 5 row
|
||||
Ctrl-w - - Decrease height by 5 row
|
||||
|
||||
-- Window Special Commands
|
||||
Ctrl-w T - Move current window to new tab
|
||||
Ctrl-w } - Preview definition in new window
|
||||
Ctrl-w z - Close preview window
|
||||
Ctrl-w ] - Split window and jump to definition
|
||||
Ctrl-w f - Split window and edit file under cursor
|
||||
Ctrl-w i - Split window and show declaration
|
||||
Ctrl-w ^ - Split window and edit alternate file
|
||||
|
||||
-- Tab
|
||||
gt :tabnext - Go to next tab
|
||||
gT :tabprevious - Go to previous tab
|
||||
{n}gt :tabnext {n} - Go to tab number {n}
|
||||
<Leader>tn :tabnew - Create a new tab - Suggested
|
||||
<Leader>tc :tabclose - Close current tab - Suggested
|
||||
<Leader>to :tabonly - Close all other tabs - Suggested
|
||||
<Leader>t{n} {n}gt - Go to tab {n} - Suggested
|
||||
<Leader>tm. :tabmove +1 - Move tab right - Suggested
|
||||
<Leader>tm, :tabmove -1 - Move tab left - Suggested
|
||||
<Leader>t] :tabnext - Go to next tab
|
||||
<Leader>t[ :tabprevious - Go to previous tab
|
||||
<Leader>tn :tabnew - Create a new tab
|
||||
<Leader>tc :tabclose - Close current tab
|
||||
<Leader>to :tabonly - Close all other tabs
|
||||
<Leader>{n} :{n}gt - Go to tab {n}
|
||||
|
||||
-- Buffer
|
||||
<Leader>bl :ls - List all buffers - Suggested
|
||||
<Leader>bd :bdelete - Delete current buffer - Suggested
|
||||
<Leader>bn :bnext - Go to next buffer - Suggested
|
||||
<Leader>bp :bprevious - Go to previous buffer - Suggested
|
||||
<Leader>b{n} :buffer {n} - Go to buffer {n} - Suggested
|
||||
<Leader>bb :b<Space> - Start buffer selection - Suggested
|
||||
<Leader>bo :bufdo bd|1bd - Delete all other buffers - Suggested
|
||||
-- note: mainly using the telescope one
|
||||
<Leader>space telescope.buffers - open buffers with telescope. there can navigate and delete
|
||||
<Leader>bl :ls - List all buffers
|
||||
<Leader>bd :bdelete - Delete current buffer
|
||||
<Leader>bn :bnext - Go to next buffer
|
||||
<Leader>bp :bprevious - Go to previous buffer
|
||||
<Leader>b{n} :buffer {n} - Go to buffer {n}
|
||||
<Leader>bb :b<Space> - Start buffer selection
|
||||
<Leader>bo :bufdo bd|1bd - Delete all other buffers
|
||||
|
||||
-- Telescope
|
||||
<Leader>sf telescope.find_files - Search Files
|
||||
<Leader>sg telescope.live_grep - Search by Grep
|
||||
<Leader>sb telescope.buffers - Search Buffers
|
||||
<Leader>sh telescope.help_tags - Search Help
|
||||
<Leader>sp telescope.projects - Search Projects
|
||||
<Leader>sm telescope.marks - Search Marks
|
||||
<Leader>sc telescope.commands - Search Commands
|
||||
<Leader>sk telescope.keymaps - Search Keymaps
|
||||
<Leader>ss telescope.git_status - Search Git Status
|
||||
<Leader>sw telescope.grep_string - Search current Word
|
||||
<Leader>sd telescope.diagnostics - Search Diagnostics
|
||||
<Leader>sr telescope.lsp_references - Search References
|
||||
<Leader>ff telescope.find_files - Search Files
|
||||
<Leader>fg telescope.live_grep - Search by Grep
|
||||
<Leader>fb telescope.buffers - Search Buffers
|
||||
<Leader>fh telescope.help_tags - Search Help
|
||||
<Leader>fp telescope.projects - Search Projects
|
||||
<Leader>fm telescope.marks - Search Marks
|
||||
<Leader>fc telescope.commands - Search Commands
|
||||
<Leader>fk telescope.keymaps - Search Keymaps
|
||||
<Leader>fs telescope.git_status - Search Git Status
|
||||
<Leader>fw telescope.grep_string - Search current Word
|
||||
<Leader>fd telescope.diagnostics - Search Diagnostics
|
||||
<Leader>fr telescope.lsp_references - Search References
|
||||
|
||||
-- Neo-tree
|
||||
<Leader>e :Neotree toggle - Explorer Toggle
|
||||
<Leader>E :Neotree focus - Explorer Focus
|
||||
<Leader>ef :Neotree float - Explorer Float
|
||||
<Leader>eb :Neotree buffers - Explorer Buffers
|
||||
<Leader>eg :Neotree git_status - Explorer Git
|
||||
<Leader>e :NvimTree toggle - Explorer Toggle
|
||||
<Leader>E :NvimTree focus - Explorer Focus
|
||||
|
||||
-- Harpoon
|
||||
<Leader>h harpoon_ui.toggle_menu - Harpoon Menu
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
-- [[
|
||||
-- TreeSitter parsers do not match directly with the filename.
|
||||
-- See: github/nvim-treesitter:lua/nvim-treesitter/parsers.lua
|
||||
-- ]]
|
||||
local M = {
|
||||
-- <filetype> = { <treesitter>, <lsp>, <linter>, <formatter> }
|
||||
-- note: lsp will match the `<path>/lsp/<file>.lua` file. The CMD the proper language-server.
|
||||
markdown = { 'markdown', 'lua_ls', 'luacheck', 'stylua' },
|
||||
javascript = { 'javascript', ' ts_ls', 'eslint', 'prettierd' },
|
||||
typescript = { 'typescript', ' ts_ls', 'eslint', 'prettierd' },
|
||||
javascriptreact = { '', ' ts_ls', 'eslint', 'prettierd' },
|
||||
typescript = { 'typescript', ' ts_ls', 'eslint', 'prettierd' },
|
||||
}
|
||||
return {
|
||||
opts = {
|
||||
view = { signcolumn = 'no' },
|
||||
renderer = {
|
||||
root_folder_label = false,
|
||||
indent_width = 2,
|
||||
indent_markers = {
|
||||
enable = true,
|
||||
icons = { corner = '│', none = '│', bottom = '' },
|
||||
},
|
||||
icons = {
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = false, -- KEEP FALSE
|
||||
git = false,
|
||||
modified = false,
|
||||
hidden = false,
|
||||
diagnostics = false,
|
||||
bookmarks = false,
|
||||
},
|
||||
glyphs = {
|
||||
default = ' ',
|
||||
folder = {
|
||||
default = '○',
|
||||
open = '●',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
hijack_cursor = true,
|
||||
sync_root_with_cwd = true,
|
||||
update_focused_file = {
|
||||
enabled = true,
|
||||
-- update_root = { enabled = true }
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,6 +1,27 @@
|
||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
local out =
|
||||
vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
|
||||
{ out, 'WarningMsg' },
|
||||
{ '\nPress any key to exit...' },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require('config.options')
|
||||
require('config.keymaps')
|
||||
require('config.autocmds')
|
||||
require('config.clipboard')
|
||||
require('config.terminal')
|
||||
require('config.lazy')
|
||||
require('lazy').setup({
|
||||
spec = { { import = 'plugins' } },
|
||||
change_detection = { notify = false },
|
||||
rocks = { enabled = false },
|
||||
})
|
||||
|
||||
@ -1,3 +1,16 @@
|
||||
-- Automatically create a scratch (no-file) buffer if Neovim starts with no files
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
callback = function()
|
||||
-- Only trigger if no file arguments are passed
|
||||
if vim.fn.argc() == 0 then
|
||||
vim.cmd('enew') -- create new buffer
|
||||
vim.bo.buftype = 'nofile'
|
||||
vim.bo.bufhidden = 'wipe'
|
||||
vim.bo.swapfile = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight when yanking (copying) text
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
callback = function()
|
||||
@ -5,13 +18,28 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set filetype on new buffers
|
||||
vim.api.nvim_create_user_command('Capture', function(opts)
|
||||
local out = vim.fn.execute(opts.args)
|
||||
vim.cmd('enew')
|
||||
vim.bo.buftype = 'nofile'
|
||||
vim.bo.bufhidden = 'hide'
|
||||
vim.bo.swapfile = false
|
||||
vim.bo.filetype = 'capture'
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(out, '\n'))
|
||||
end, { nargs = '+', complete = 'command' })
|
||||
-- Disable comment continuation only when using 'o'/'O', but keep it for <Enter>
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.opt_local.formatoptions:remove('o')
|
||||
end,
|
||||
})
|
||||
|
||||
-- Show cursor line only in active window
|
||||
vim.api.nvim_create_autocmd({ 'InsertLeave', 'WinEnter' }, {
|
||||
callback = function()
|
||||
if vim.w.auto_cursorline then
|
||||
vim.wo.cursorline = true
|
||||
vim.w.auto_cursorline = nil
|
||||
end
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ 'InsertEnter', 'WinLeave' }, {
|
||||
callback = function()
|
||||
if vim.wo.cursorline then
|
||||
vim.w.auto_cursorline = true
|
||||
vim.wo.cursorline = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@ -1,44 +1,54 @@
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>q',
|
||||
vim.diagnostic.setloclist,
|
||||
{ desc = 'Open diagnostic [Q]uickfix list' }
|
||||
)
|
||||
local map = vim.keymap.set
|
||||
|
||||
vim.keymap.set('i', 'jk', '<Esc>', { desc = 'Exit insert mode with jk' })
|
||||
vim.keymap.set('c', 'jk', '<C-c>', { desc = 'Exit command/search mode with jk' })
|
||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>', { desc = 'Clear highlights' })
|
||||
map('n', '<leader>q', vim.diagnostic.setloclist)
|
||||
|
||||
-- Prevent "x" from overriding the register
|
||||
vim.keymap.set('n', 'x', '"_x')
|
||||
map({ 'i', 'c' }, 'jk', '<Esc>')
|
||||
map('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||
|
||||
-- Prevent overriding the register
|
||||
map('n', 'x', '"_x')
|
||||
|
||||
-- Window Navigation
|
||||
vim.keymap.set('n', '<C-h>', '<C-w>h', { desc = 'Move focus to the left window' })
|
||||
vim.keymap.set('n', '<C-l>', '<C-w>l', { desc = 'Move focus to the right window' })
|
||||
vim.keymap.set('n', '<C-j>', '<C-w>j', { desc = 'Move focus to the lower window' })
|
||||
vim.keymap.set('n', '<C-k>', '<C-w>k', { desc = 'Move focus to the upper window' })
|
||||
map('n', '<C-h>', '<C-w>h')
|
||||
map('n', '<C-l>', '<C-w>l')
|
||||
map('n', '<C-j>', '<C-w>j')
|
||||
map('n', '<C-k>', '<C-w>k')
|
||||
|
||||
-- Tab management
|
||||
vim.keymap.set('n', '<Leader>tn', ':tabnew<CR>', { desc = '[T]ab [N]ew' })
|
||||
vim.keymap.set('n', '<Leader>tc', ':tabclose<CR>', { desc = '[T]ab [C]lose' })
|
||||
vim.keymap.set('n', '<Leader>to', ':tabonly<CR>', { desc = '[T]ab [O]nly' })
|
||||
vim.keymap.set('n', '<Leader>tl', ':tabnext<CR>', { desc = '[T]ab Next' })
|
||||
vim.keymap.set('n', '<Leader>th', ':tabprevious<CR>', { desc = '[T]ab Previous' })
|
||||
vim.keymap.set('n', '<Leader>tm.', ':tabmove +1<CR>', { desc = '[T]ab [M]ove Right' })
|
||||
vim.keymap.set('n', '<Leader>tm,', ':tabmove -1<CR>', { desc = '[T]ab [M]ove Left' })
|
||||
map('n', '<Leader>tn', ':tabnew<CR>')
|
||||
map('n', '<Leader>tc', ':tabclose<CR>')
|
||||
map('n', '<Leader>tl', ':tabnext<CR>')
|
||||
map('n', '<Leader>th', ':tabprevious<CR>')
|
||||
map('n', '<Leader>tm.', ':tabmove +1<CR>')
|
||||
map('n', '<Leader>tm,', ':tabmove -1<CR>')
|
||||
for i = 1, 9 do
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
string.format('<Leader>%d', i),
|
||||
string.format('%dgt', i),
|
||||
{ desc = string.format('[T]ab %d', i) }
|
||||
)
|
||||
map('n', string.format('<Leader>%d', i), string.format('%dgt', i))
|
||||
end
|
||||
|
||||
-- Buffer Management
|
||||
vim.keymap.set('n', '<Leader>bl', ':ls<CR>', { desc = '[B]uffer [L]ist' })
|
||||
vim.keymap.set('n', '<Leader>bd', ':bdelete<CR>', { desc = '[B]uffer [D]elete' })
|
||||
vim.keymap.set('n', ']b', ':bnext<CR>', { desc = '[B]uffer [N]ext' })
|
||||
vim.keymap.set('n', '[b', ':bprevious<CR>', { desc = '[B]uffer [P]revious' })
|
||||
vim.keymap.set('n', '<Leader>bb', ':b<Space>', { desc = '[B]uffer Select' })
|
||||
vim.keymap.set('n', '<Leader>bo', ':bufdo bd|1bd<CR>', { desc = '[B]uffer Delete Others' })
|
||||
map('n', '<Leader>bl', ':ls<CR>')
|
||||
map('n', '<Leader>bd', ':bdelete<CR>')
|
||||
map('n', ']b', ':bnext<CR>')
|
||||
map('n', '[b', ':bprevious<CR>')
|
||||
map('n', '<Leader>bb', ':b<Space>')
|
||||
map('n', '<Leader>bo', ':bufdo bd|1bd<CR>')
|
||||
|
||||
-- Terminal
|
||||
map('n', '<leader>tt', ':TermDefault<CR>')
|
||||
map('n', '<leader>tr', ':TermRelative<CR>')
|
||||
map('n', '<leader>ts', ':TermSplit<CR>')
|
||||
map('n', '<leader>tv', ':TermVSplit<CR>')
|
||||
|
||||
-- Terminal mode mappings
|
||||
local tn = '<C-\\><C-n>'
|
||||
map('t', '<Esc>', tn)
|
||||
map('t', 'jk', tn)
|
||||
map('t', '<C-w>', tn .. '<C-w>')
|
||||
map('t', '<C-h>', '<cmd>wincmd h<CR>')
|
||||
map('t', '<C-j>', '<cmd>wincmd j<CR>')
|
||||
map('t', '<C-k>', '<cmd>wincmd k<CR>')
|
||||
map('t', '<C-l>', '<cmd>wincmd l<CR>')
|
||||
|
||||
-- File explorer
|
||||
vim.keymap.set('n', '<leader>e', '<cmd>NvimTreeToggle<CR>')
|
||||
vim.keymap.set('n', '<leader>E', '<cmd>NvimTreeOpen<CR>')
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
local out =
|
||||
vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
|
||||
{ out, 'WarningMsg' },
|
||||
{ '\nPress any key to exit...' },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require('lazy').setup({
|
||||
spec = { { import = 'plugins' } },
|
||||
change_detection = { notify = false },
|
||||
rocks = { enabled = false },
|
||||
})
|
||||
@ -1,19 +1,28 @@
|
||||
-- Map Leader
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
-- use nvim-tree instead
|
||||
vim.g.loaded_netrw = 1
|
||||
-- Disable features
|
||||
vim.loader.enable()
|
||||
vim.g.loaded_gzip = 1
|
||||
vim.g.loaded_tar = 1
|
||||
vim.g.loaded_tarPlugin = 1
|
||||
vim.g.loaded_zip = 1
|
||||
vim.g.loaded_zipPlugin = 1
|
||||
vim.g.loaded_getscript = 1
|
||||
vim.g.loaded_getscriptPlugin = 1
|
||||
vim.g.loaded_vimball = 1
|
||||
vim.g.loaded_vimballPlugin = 1
|
||||
vim.g.loaded_matchit = 1
|
||||
vim.g.loaded_2html_plugin = 1
|
||||
vim.g.loaded_rrhelper = 1
|
||||
vim.g.loaded_netrw = 1 -- use nvim-tree instead
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.g.loaded_matchparen = 1
|
||||
|
||||
vim.opt.formatoptions:remove('o')
|
||||
|
||||
vim.opt.modeline = true
|
||||
vim.opt.modelines = 5
|
||||
|
||||
-- UI and appearance
|
||||
vim.opt.termguicolors = true -- Disable TrueColor
|
||||
-- UI
|
||||
vim.g.have_nerd_font = true
|
||||
vim.opt.termguicolors = true -- TrueColor
|
||||
vim.opt.colorcolumn = '100' -- Vertical guide at column 100
|
||||
vim.opt.signcolumn = 'no' -- Hide sign column
|
||||
vim.opt.cursorline = true -- Highlight current line
|
||||
@ -21,35 +30,39 @@ vim.opt.guicursor = 'n-v-i-c:block' -- Block cursor shape
|
||||
vim.opt.number = true -- Show absolute line numbers
|
||||
vim.opt.relativenumber = true -- Show relative numbers
|
||||
vim.opt.statusline = '%F%m%r%h%w%=%l,%c %P ' -- Custom statusline
|
||||
vim.opt.swapfile = false
|
||||
|
||||
vim.opt.wrap = false -- Line wrapping
|
||||
vim.opt.linebreak = true -- Wrap long lines at convenient points
|
||||
vim.opt.breakindent = true -- Preserve indent when wrapping long lines
|
||||
|
||||
-- Editing behavior
|
||||
-- Editing
|
||||
vim.opt.shiftwidth = 2 -- Number of spaces to use for (auto)indent
|
||||
vim.opt.tabstop = 2 -- Number of spaces that a <Tab> in file counts for
|
||||
vim.opt.softtabstop = 2 -- Number of spaces when pressing <Tab> in insert mode
|
||||
vim.opt.expandtab = true -- Use spaces instead of literal tab characters
|
||||
vim.opt.autoindent = true -- Copy indent from the current line when starting a new one
|
||||
vim.opt.smartindent = true -- Automatically inserts indents in code blocks (for C-like languages)
|
||||
vim.opt.completeopt = { 'menuone' }
|
||||
|
||||
-- Scroll
|
||||
-- Scroll and mouse
|
||||
vim.opt.scrolloff = 10 -- Keep lines visible above/below cursor
|
||||
vim.opt.mousescroll = 'hor:1,ver:1' -- Scroll lines/columns
|
||||
vim.opt.mouse = 'a' -- Enable mouse mode
|
||||
|
||||
-- Search and substitution
|
||||
-- Search
|
||||
vim.opt.ignorecase = true -- Case-insensitive search
|
||||
vim.opt.smartcase = true -- Smart-case search
|
||||
vim.opt.inccommand = 'split' -- Live substitution preview
|
||||
|
||||
-- Splits and windows
|
||||
-- Splits
|
||||
vim.opt.splitright = true -- Vertical splits to the right
|
||||
vim.opt.splitbelow = true -- Horizontal splits below
|
||||
|
||||
-- Performance and persistence
|
||||
vim.opt.undofile = false -- Save undo history
|
||||
vim.opt.undofile = true -- Save undo history
|
||||
vim.opt.undodir = vim.fn.stdpath('state') .. '/undo'
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.updatetime = 250 -- Faster updates
|
||||
vim.opt.timeoutlen = 300 -- Shorter keymap timeout
|
||||
|
||||
@ -1,34 +1,62 @@
|
||||
vim.api.nvim_create_autocmd("TermOpen", {
|
||||
group = vim.api.nvim_create_augroup("custom-term-open", { clear = true }),
|
||||
local term_group = vim.api.nvim_create_augroup('custom-term-open', { clear = true })
|
||||
vim.api.nvim_create_autocmd('TermOpen', {
|
||||
group = term_group,
|
||||
callback = function()
|
||||
vim.opt_local.number = false
|
||||
vim.opt_local.relativenumber = false
|
||||
vim.opt_local.scrolloff = 0
|
||||
|
||||
vim.bo.filetype = "terminal"
|
||||
vim.cmd("startinsert")
|
||||
vim.bo.filetype = 'terminal'
|
||||
vim.cmd.startinsert()
|
||||
end,
|
||||
})
|
||||
|
||||
-- Open a relative terminal in the current file’s directory
|
||||
vim.keymap.set("n", "<leader>ter", function()
|
||||
vim.cmd.edit(string.format("term://%s//zsh", vim.fn.expand("%:p:h")))
|
||||
end, { desc = "[T]erminal [R]elative" })
|
||||
-- Close all terminal buffers before quitting
|
||||
vim.api.nvim_create_autocmd('QuitPre', {
|
||||
group = vim.api.nvim_create_augroup('shoutoff_terminals', { clear = true }),
|
||||
callback = function()
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].buftype == 'terminal' then
|
||||
vim.api.nvim_buf_delete(buf, { force = true })
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Open a split terminal at the bottom
|
||||
vim.keymap.set("n", "<leader>ts", function()
|
||||
vim.cmd.new()
|
||||
vim.cmd.wincmd("J")
|
||||
-- Insert when re-entering a terminal window (after switching back)
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
group = term_group,
|
||||
pattern = 'term://*',
|
||||
callback = function()
|
||||
if vim.bo.buftype == 'terminal' and vim.fn.mode() ~= 'i' then
|
||||
vim.cmd.startinsert()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local function open_default()
|
||||
vim.cmd('terminal')
|
||||
end
|
||||
|
||||
local function open_relative()
|
||||
local shell = vim.o.shell or 'zsh'
|
||||
local dir = vim.fn.expand('%:p:h')
|
||||
vim.cmd(string.format('edit term://%s//%s', dir, shell))
|
||||
end
|
||||
|
||||
local function open_split()
|
||||
vim.cmd('new')
|
||||
vim.cmd('wincmd J')
|
||||
vim.api.nvim_win_set_height(0, 12)
|
||||
vim.wo.winfixheight = true
|
||||
vim.cmd.term()
|
||||
end, { desc = "[T]erminal [S]plit" })
|
||||
vim.cmd('term')
|
||||
end
|
||||
|
||||
-- Simple terminal open
|
||||
vim.keymap.set("n", "<Leader>tet", ":terminal<CR>", { desc = "[T]erminal" })
|
||||
|
||||
-- Terminal mode keymaps
|
||||
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { desc = "Terminal Normal Mode" })
|
||||
vim.keymap.set("t", "jk", "<C-\\><C-n>", { desc = "Terminal Normal Mode" })
|
||||
vim.keymap.set("t", "<C-w>", "<C-\\><C-n><C-w>", { desc = "Terminal Window Command" })
|
||||
local function open_vertical()
|
||||
vim.cmd('vsplit')
|
||||
vim.cmd('term')
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('TermDefault', open_default, {})
|
||||
vim.api.nvim_create_user_command('TermRelative', open_relative, {})
|
||||
vim.api.nvim_create_user_command('TermSplit', open_split, {})
|
||||
vim.api.nvim_create_user_command('TermVSplit', open_vertical, {})
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
vim.keymap.set('n', '<leader>e', '<cmd>NvimTreeToggle<CR>')
|
||||
|
||||
local function my_on_attach(bufnr)
|
||||
local api = require('nvim-tree.api')
|
||||
local opts = { buffer = bufnr }
|
||||
@ -95,7 +93,6 @@ return {
|
||||
},
|
||||
|
||||
hijack_cursor = true,
|
||||
hijack_unnamed_buffer_when_opening = true,
|
||||
prefer_startup_root = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
return {
|
||||
{
|
||||
'windwp/nvim-ts-autotag',
|
||||
opts = {
|
||||
autotag = {
|
||||
enable = true,
|
||||
enable_close = true,
|
||||
enable_rename = true,
|
||||
enable_close_on_slash = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- 'windwp/nvim-ts-autotag',
|
||||
-- opts = {
|
||||
-- autotag = {
|
||||
-- enable = true,
|
||||
-- enable_close = true,
|
||||
-- enable_rename = true,
|
||||
-- enable_close_on_slash = true,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
{
|
||||
'windwp/nvim-autopairs',
|
||||
event = 'InsertEnter',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user