diff --git a/config/linux-dev/nvim/docs/commands.md b/config/linux-dev/nvim/docs/commands.md new file mode 100644 index 0000000..137b984 --- /dev/null +++ b/config/linux-dev/nvim/docs/commands.md @@ -0,0 +1,109 @@ +#============================================================ +# Neovim Command Reference (Core Commands) +#============================================================ + + +#============================================================ +# FILE & SESSION MANAGEMENT +#============================================================ +:w (write) Save current buffer +:w Write to (does NOT rename buffer) +:sav (saveas) Save to 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) Edit in current window (new buffer) +:e! Revert buffer to last saved version (discard changes) +:enew Create new empty buffer +:r (read) Read 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 Go to buffer by number +:b Go to buffer by (partial) name +:bd (bdelete) [] Delete current (or given) buffer +:bw (bwipeout) [] 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) [] Split horizontally (optionally open ) +:vsp (vsplit) [] Split vertically (optionally open ) +: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 [] Open new tab (optionally edit ) +:tabn (tabnext) Go to next tab +:tabp (tabprev) Go to previous tab +:tabm (tabmove) Move current tab to position +:tabfirst Jump to first tab +:tablast Jump to last tab +:tabc (tabclose) Close current tab +:tabo (tabonly) Close all other tabs +:tabdo Execute 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) + diff --git a/config/linux-dev/nvim/docs/docs.md b/config/linux-dev/nvim/docs/docs.md index 77edd43..a6a6ddd 100644 --- a/config/linux-dev/nvim/docs/docs.md +++ b/config/linux-dev/nvim/docs/docs.md @@ -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 diff --git a/config/linux-dev/nvim/docs/keymaps.md b/config/linux-dev/nvim/docs/keymaps.md new file mode 100644 index 0000000..04022ab --- /dev/null +++ b/config/linux-dev/nvim/docs/keymaps.md @@ -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 +gt Go to tab number + + +#============================================================ +# 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. + diff --git a/config/linux-dev/nvim/docs/neovim-actions.md b/config/linux-dev/nvim/docs/neovim-actions.md index b60d638..513afbc 100644 --- a/config/linux-dev/nvim/docs/neovim-actions.md +++ b/config/linux-dev/nvim/docs/neovim-actions.md @@ -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} -tn :tabnew - Create a new tab - Suggested -tc :tabclose - Close current tab - Suggested -to :tabonly - Close all other tabs - Suggested -t{n} {n}gt - Go to tab {n} - Suggested -tm. :tabmove +1 - Move tab right - Suggested -tm, :tabmove -1 - Move tab left - Suggested +t] :tabnext - Go to next tab +t[ :tabprevious - Go to previous tab +tn :tabnew - Create a new tab +tc :tabclose - Close current tab +to :tabonly - Close all other tabs +{n} :{n}gt - Go to tab {n} -- Buffer -bl :ls - List all buffers - Suggested -bd :bdelete - Delete current buffer - Suggested -bn :bnext - Go to next buffer - Suggested -bp :bprevious - Go to previous buffer - Suggested -b{n} :buffer {n} - Go to buffer {n} - Suggested -bb :b - Start buffer selection - Suggested -bo :bufdo bd|1bd - Delete all other buffers - Suggested +-- note: mainly using the telescope one +space telescope.buffers - open buffers with telescope. there can navigate and delete +bl :ls - List all buffers +bd :bdelete - Delete current buffer +bn :bnext - Go to next buffer +bp :bprevious - Go to previous buffer +b{n} :buffer {n} - Go to buffer {n} +bb :b - Start buffer selection +bo :bufdo bd|1bd - Delete all other buffers -- Telescope -sf telescope.find_files - Search Files -sg telescope.live_grep - Search by Grep -sb telescope.buffers - Search Buffers -sh telescope.help_tags - Search Help -sp telescope.projects - Search Projects -sm telescope.marks - Search Marks -sc telescope.commands - Search Commands -sk telescope.keymaps - Search Keymaps -ss telescope.git_status - Search Git Status -sw telescope.grep_string - Search current Word -sd telescope.diagnostics - Search Diagnostics -sr telescope.lsp_references - Search References +ff telescope.find_files - Search Files +fg telescope.live_grep - Search by Grep +fb telescope.buffers - Search Buffers +fh telescope.help_tags - Search Help +fp telescope.projects - Search Projects +fm telescope.marks - Search Marks +fc telescope.commands - Search Commands +fk telescope.keymaps - Search Keymaps +fs telescope.git_status - Search Git Status +fw telescope.grep_string - Search current Word +fd telescope.diagnostics - Search Diagnostics +fr telescope.lsp_references - Search References -- Neo-tree -e :Neotree toggle - Explorer Toggle -E :Neotree focus - Explorer Focus -ef :Neotree float - Explorer Float -eb :Neotree buffers - Explorer Buffers -eg :Neotree git_status - Explorer Git +e :NvimTree toggle - Explorer Toggle +E :NvimTree focus - Explorer Focus -- Harpoon h harpoon_ui.toggle_menu - Harpoon Menu diff --git a/config/linux-dev/nvim/docs/test.jsx b/config/linux-dev/nvim/docs/test.jsx deleted file mode 100644 index e69de29..0000000 diff --git a/config/linux-dev/nvim/docs/test.tsx b/config/linux-dev/nvim/docs/test.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/config/linux-dev/nvim/docs/tmp.lua b/config/linux-dev/nvim/docs/tmp.lua deleted file mode 100644 index ba98de4..0000000 --- a/config/linux-dev/nvim/docs/tmp.lua +++ /dev/null @@ -1,51 +0,0 @@ --- [[ --- TreeSitter parsers do not match directly with the filename. --- See: github/nvim-treesitter:lua/nvim-treesitter/parsers.lua --- ]] -local M = { - -- = { , , , } - -- note: lsp will match the `/lsp/.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 } - }, - }, -} diff --git a/config/linux-dev/nvim/init.lua b/config/linux-dev/nvim/init.lua index 8044b05..61a9cac 100644 --- a/config/linux-dev/nvim/init.lua +++ b/config/linux-dev/nvim/init.lua @@ -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 }, +}) diff --git a/config/linux-dev/nvim/lua/config/autocmds.lua b/config/linux-dev/nvim/lua/config/autocmds.lua index 8a660a4..d05d053 100644 --- a/config/linux-dev/nvim/lua/config/autocmds.lua +++ b/config/linux-dev/nvim/lua/config/autocmds.lua @@ -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 +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, +}) diff --git a/config/linux-dev/nvim/lua/config/keymaps.lua b/config/linux-dev/nvim/lua/config/keymaps.lua index aa2f95c..67bfac7 100644 --- a/config/linux-dev/nvim/lua/config/keymaps.lua +++ b/config/linux-dev/nvim/lua/config/keymaps.lua @@ -1,44 +1,54 @@ -vim.keymap.set( - 'n', - 'q', - vim.diagnostic.setloclist, - { desc = 'Open diagnostic [Q]uickfix list' } -) +local map = vim.keymap.set -vim.keymap.set('i', 'jk', '', { desc = 'Exit insert mode with jk' }) -vim.keymap.set('c', 'jk', '', { desc = 'Exit command/search mode with jk' }) -vim.keymap.set('n', '', 'nohlsearch', { desc = 'Clear highlights' }) +map('n', 'q', vim.diagnostic.setloclist) --- Prevent "x" from overriding the register -vim.keymap.set('n', 'x', '"_x') +map({ 'i', 'c' }, 'jk', '') +map('n', '', 'nohlsearch') + +-- Prevent overriding the register +map('n', 'x', '"_x') -- Window Navigation -vim.keymap.set('n', '', 'h', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', 'l', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', 'j', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', 'k', { desc = 'Move focus to the upper window' }) +map('n', '', 'h') +map('n', '', 'l') +map('n', '', 'j') +map('n', '', 'k') -- Tab management -vim.keymap.set('n', 'tn', ':tabnew', { desc = '[T]ab [N]ew' }) -vim.keymap.set('n', 'tc', ':tabclose', { desc = '[T]ab [C]lose' }) -vim.keymap.set('n', 'to', ':tabonly', { desc = '[T]ab [O]nly' }) -vim.keymap.set('n', 'tl', ':tabnext', { desc = '[T]ab Next' }) -vim.keymap.set('n', 'th', ':tabprevious', { desc = '[T]ab Previous' }) -vim.keymap.set('n', 'tm.', ':tabmove +1', { desc = '[T]ab [M]ove Right' }) -vim.keymap.set('n', 'tm,', ':tabmove -1', { desc = '[T]ab [M]ove Left' }) +map('n', 'tn', ':tabnew') +map('n', 'tc', ':tabclose') +map('n', 'tl', ':tabnext') +map('n', 'th', ':tabprevious') +map('n', 'tm.', ':tabmove +1') +map('n', 'tm,', ':tabmove -1') for i = 1, 9 do - vim.keymap.set( - 'n', - string.format('%d', i), - string.format('%dgt', i), - { desc = string.format('[T]ab %d', i) } - ) + map('n', string.format('%d', i), string.format('%dgt', i)) end -- Buffer Management -vim.keymap.set('n', 'bl', ':ls', { desc = '[B]uffer [L]ist' }) -vim.keymap.set('n', 'bd', ':bdelete', { desc = '[B]uffer [D]elete' }) -vim.keymap.set('n', ']b', ':bnext', { desc = '[B]uffer [N]ext' }) -vim.keymap.set('n', '[b', ':bprevious', { desc = '[B]uffer [P]revious' }) -vim.keymap.set('n', 'bb', ':b', { desc = '[B]uffer Select' }) -vim.keymap.set('n', 'bo', ':bufdo bd|1bd', { desc = '[B]uffer Delete Others' }) +map('n', 'bl', ':ls') +map('n', 'bd', ':bdelete') +map('n', ']b', ':bnext') +map('n', '[b', ':bprevious') +map('n', 'bb', ':b') +map('n', 'bo', ':bufdo bd|1bd') + +-- Terminal +map('n', 'tt', ':TermDefault') +map('n', 'tr', ':TermRelative') +map('n', 'ts', ':TermSplit') +map('n', 'tv', ':TermVSplit') + +-- Terminal mode mappings +local tn = '' +map('t', '', tn) +map('t', 'jk', tn) +map('t', '', tn .. '') +map('t', '', 'wincmd h') +map('t', '', 'wincmd j') +map('t', '', 'wincmd k') +map('t', '', 'wincmd l') + +-- File explorer +vim.keymap.set('n', 'e', 'NvimTreeToggle') +vim.keymap.set('n', 'E', 'NvimTreeOpen') diff --git a/config/linux-dev/nvim/lua/config/lazy.lua b/config/linux-dev/nvim/lua/config/lazy.lua deleted file mode 100644 index 72db04a..0000000 --- a/config/linux-dev/nvim/lua/config/lazy.lua +++ /dev/null @@ -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 }, -}) diff --git a/config/linux-dev/nvim/lua/config/options.lua b/config/linux-dev/nvim/lua/config/options.lua index 75ad64b..74ca036 100644 --- a/config/linux-dev/nvim/lua/config/options.lua +++ b/config/linux-dev/nvim/lua/config/options.lua @@ -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 in file counts for vim.opt.softtabstop = 2 -- Number of spaces when pressing 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 diff --git a/config/linux-dev/nvim/lua/config/terminal.lua b/config/linux-dev/nvim/lua/config/terminal.lua index d00cc55..6221433 100644 --- a/config/linux-dev/nvim/lua/config/terminal.lua +++ b/config/linux-dev/nvim/lua/config/terminal.lua @@ -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", "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", "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", "tet", ":terminal", { desc = "[T]erminal" }) - --- Terminal mode keymaps -vim.keymap.set("t", "", "", { desc = "Terminal Normal Mode" }) -vim.keymap.set("t", "jk", "", { desc = "Terminal Normal Mode" }) -vim.keymap.set("t", "", "", { 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, {}) diff --git a/config/linux-dev/nvim/lua/plugins/filetree.lua b/config/linux-dev/nvim/lua/plugins/filetree.lua index b39d515..a8113fd 100644 --- a/config/linux-dev/nvim/lua/plugins/filetree.lua +++ b/config/linux-dev/nvim/lua/plugins/filetree.lua @@ -1,5 +1,3 @@ -vim.keymap.set('n', 'e', 'NvimTreeToggle') - 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, diff --git a/config/linux-dev/nvim/lua/plugins/miscellaneous.lua b/config/linux-dev/nvim/lua/plugins/miscellaneous.lua index aa21fff..479efd9 100644 --- a/config/linux-dev/nvim/lua/plugins/miscellaneous.lua +++ b/config/linux-dev/nvim/lua/plugins/miscellaneous.lua @@ -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',