refactor
This commit is contained in:
commit
66575f2919
10 changed files with 419 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Ignore plugin manager files
|
||||
plugged/
|
||||
autoload/
|
||||
|
||||
# Ignore undo files (if set with `set undodir=~/.vim/undodir`)
|
||||
undodir/
|
||||
|
||||
.netrwhist
|
||||
6
colors.vim
Normal file
6
colors.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
set termguicolors
|
||||
|
||||
let g:tokyonight_style = 'night' " available: night, storm
|
||||
let g:tokyonight_enable_italic = 1
|
||||
|
||||
colorscheme tokyonight
|
||||
20
fzf.vim
Normal file
20
fzf.vim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
" FZF keymaps (requires Plug 'junegunn/fzf.vim')
|
||||
|
||||
" Files
|
||||
nnoremap <leader>ff :Files<CR>
|
||||
nnoremap <leader>fo :History<CR>
|
||||
nnoremap <leader>fb :Buffers<CR>
|
||||
nnoremap <leader>fq :CList<CR> " For quickfix list
|
||||
nnoremap <leader>fh :Helptags<CR>
|
||||
|
||||
" Grep current string
|
||||
nnoremap <leader>fs :Rg <C-r><C-w><CR>
|
||||
|
||||
" Grep input string (fzf prompt)
|
||||
nnoremap <leader>fg :Rg<Space>
|
||||
|
||||
" Grep for current file name (without extension)
|
||||
nnoremap <leader>fc :execute 'Rg ' . expand('%:t:r')<CR>
|
||||
|
||||
" Find files in your Vim config
|
||||
nnoremap <leader>fi :Files ~/.vim<CR>
|
||||
59
keybinds.vim
Normal file
59
keybinds.vim
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
" Set leader key
|
||||
let mapleader = " "
|
||||
|
||||
" Open netrw with <leader>cd
|
||||
nnoremap <leader>cd :Ex<CR>
|
||||
|
||||
" Move selected lines up/down (like Alt-Up/Down)
|
||||
vnoremap J :m '>+1<CR>gv=gv
|
||||
vnoremap K :m '<-2<CR>gv=gv
|
||||
|
||||
" Join lines with cursor preserved
|
||||
nnoremap J mzJ`z
|
||||
|
||||
" Scroll half-page and center cursor
|
||||
nnoremap <C-d> <C-d>zz
|
||||
nnoremap <C-u> <C-u>zz
|
||||
|
||||
" Center on next/previous search result
|
||||
nnoremap n nzzzv
|
||||
nnoremap N Nzzzv
|
||||
|
||||
" Paste without overwriting clipboard
|
||||
xnoremap <leader>p "_dP
|
||||
nnoremap <leader>d "_d
|
||||
vnoremap <leader>d "_d
|
||||
|
||||
" Make <C-c> behave like <Esc> in insert mode
|
||||
inoremap <C-c> <Esc>
|
||||
|
||||
" Navigate quickfix list using Ctrl-j/k
|
||||
nnoremap <C-j> :lnext<CR>
|
||||
nnoremap <C-k> :lprev<CR>
|
||||
nnoremap <leader>cl :lclose<CR>
|
||||
|
||||
" Disable Ex mode (accidental Q)
|
||||
nnoremap Q <nop>
|
||||
|
||||
" Location list navigation
|
||||
nnoremap <leader>k :lnext<CR>zz
|
||||
nnoremap <leader>j :lprev<CR>zz
|
||||
|
||||
" Doge doc generator
|
||||
nnoremap <leader>dg :DogeGenerate<CR>
|
||||
|
||||
" Substitute word under cursor on line
|
||||
nnoremap <leader>s :s/\<<C-r><C-w>\>//gI<Left><Left><Left>
|
||||
|
||||
" Make current file executable
|
||||
nnoremap <leader>x :!chmod +x %<CR>
|
||||
|
||||
" Yank via OSCYank
|
||||
nmap <leader>y <Plug>OSCYankOperator
|
||||
vmap <leader>y <Plug>OSCYankVisual
|
||||
|
||||
" Reload vimrc (adjust path as needed)
|
||||
nnoremap <leader>rl :source ~/.vim/vimrc<CR>
|
||||
|
||||
" Source current file
|
||||
nnoremap <leader><leader> :so<CR>
|
||||
17
lightline.vim
Normal file
17
lightline.vim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
set laststatus=2
|
||||
let g:lightline = {
|
||||
\ 'colorscheme' : 'tokyonight',
|
||||
\ 'active': {
|
||||
\ 'left': [ [ 'mode', 'paste' ],
|
||||
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ],
|
||||
\ 'right': [ [ 'lineinfo' ], [ 'fileformat', 'fileencoding', 'filetype' ] ]
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'gitbranch': 'FugitiveHead',
|
||||
\ 'filename': 'LightlineFilename'
|
||||
\ }
|
||||
\ }
|
||||
|
||||
function! LightlineFilename()
|
||||
return expand('%:t') !=# '' ? expand('%:t') : '[No Name]'
|
||||
endfunction
|
||||
33
lsp.vim
Normal file
33
lsp.vim
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
" Enable diagnostics highlighting
|
||||
let lspOpts = #{autoHighlightDiags: v:true}
|
||||
autocmd User LspSetup call LspOptionsSet(lspOpts)
|
||||
let lspServers = [
|
||||
\ #{
|
||||
\ name: 'rust-analyzer',
|
||||
\ filetype: ['rust'],
|
||||
\ path: 'rust-analyzer',
|
||||
\ args: []
|
||||
\ }
|
||||
\ ]
|
||||
|
||||
autocmd User LspSetup call LspAddServer(lspServers)
|
||||
|
||||
" Key mappings
|
||||
nnoremap gd :LspGotoDefinition<CR>
|
||||
nnoremap gr :LspShowReferences<CR>
|
||||
nnoremap K :LspHover<CR>
|
||||
nnoremap gl :LspDiag current<CR>
|
||||
nnoremap <leader>nd :LspDiag next \| LspDiag current<CR>
|
||||
nnoremap <leader>pd :LspDiag prev \| LspDiag current<CR>
|
||||
inoremap <silent> <C-Space> <C-x><C-o>
|
||||
|
||||
" Set omnifunc for completion
|
||||
autocmd FileType php setlocal omnifunc=lsp#complete
|
||||
|
||||
" Custom diagnostic sign characters
|
||||
autocmd User LspSetup call LspOptionsSet(#{
|
||||
\ diagSignErrorText: '✘',
|
||||
\ diagSignWarningText: '▲',
|
||||
\ diagSignInfoText: '»',
|
||||
\ diagSignHintText: '⚑',
|
||||
\ })
|
||||
43
options.vim
Normal file
43
options.vim
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
filetype plugin indent on
|
||||
set softtabstop=4
|
||||
set smartindent
|
||||
set showmatch
|
||||
syntax on
|
||||
" Line numbers
|
||||
set number
|
||||
set relativenumber
|
||||
|
||||
" Indentation and tabs
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
set autoindent
|
||||
set expandtab
|
||||
|
||||
" Search
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set incsearch
|
||||
|
||||
" Appearance
|
||||
set background=dark
|
||||
set signcolumn=yes
|
||||
set cursorline
|
||||
set colorcolumn=80
|
||||
|
||||
" Backspace behavior
|
||||
set backspace=indent,eol,start
|
||||
|
||||
" Split window behavior
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
" dw/diw/ciw treat dash-separated words as single word
|
||||
set iskeyword+=-
|
||||
|
||||
" Keep cursor 8 lines from top/bottom
|
||||
set scrolloff=8
|
||||
|
||||
" Cursor responsiveness
|
||||
set updatetime=50
|
||||
|
||||
set laststatus=2
|
||||
28
plugins.vim
Normal file
28
plugins.vim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
" plugins.vim - Dead simple plugin manager
|
||||
" Just source this file in your vimrc
|
||||
let s:plugin_dir = expand('~/.vim/plugged')
|
||||
|
||||
" Install a plugin if it doesn't exist
|
||||
function! s:ensure(repo)
|
||||
let name = split(a:repo, '/')[-1]
|
||||
let path = s:plugin_dir . '/' . name
|
||||
|
||||
if !isdirectory(path)
|
||||
if !isdirectory(s:plugin_dir)
|
||||
call mkdir(s:plugin_dir, 'p')
|
||||
endif
|
||||
execute '!git clone --depth=1 https://github.com/' . a:repo . ' ' . shellescape(path)
|
||||
endif
|
||||
|
||||
execute 'set runtimepath+=' . fnameescape(path)
|
||||
endfunction
|
||||
|
||||
" Your plugins
|
||||
call s:ensure('junegunn/fzf')
|
||||
call s:ensure('junegunn/fzf.vim')
|
||||
call s:ensure('tomasiser/vim-code-dark')
|
||||
call s:ensure('ghifarit53/tokyonight-vim')
|
||||
call s:ensure('yegappan/lsp')
|
||||
call s:ensure('ojroques/vim-oscyank')
|
||||
call s:ensure('tpope/vim-commentary')
|
||||
call s:ensure('itchyny/lightline.vim')
|
||||
198
readme.org
Normal file
198
readme.org
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
#+TITLE: Vim Configuration
|
||||
#+AUTHOR: Tony
|
||||
#+DATE: 2025
|
||||
|
||||
* Keybindings
|
||||
|
||||
** General
|
||||
| Key | Mode | Action |
|
||||
|-----------------+--------+-------------------------------------|
|
||||
| =<Space>= | - | Leader key |
|
||||
| =<leader>cd= | Normal | Open netrw file explorer |
|
||||
| =<leader>rl= | Normal | Reload vimrc |
|
||||
| =<leader><leader>= | Normal | Source current file |
|
||||
| =<C-c>= | Insert | Behave like =<Esc>= |
|
||||
| =Q= | Normal | Disabled (no Ex mode) |
|
||||
|
||||
** Editing
|
||||
| Key | Mode | Action |
|
||||
|--------------+--------+----------------------------------------|
|
||||
| =J= | Visual | Move selected lines down |
|
||||
| =K= | Visual | Move selected lines up |
|
||||
| =J= | Normal | Join lines with cursor preserved |
|
||||
| =<leader>p= | Visual | Paste without overwriting clipboard |
|
||||
| =<leader>d= | Normal/Visual | Delete without overwriting clipboard |
|
||||
| =<leader>s= | Normal | Substitute word under cursor on line |
|
||||
| =<leader>x= | Normal | Make current file executable |
|
||||
| =<leader>dg= | Normal | Generate documentation (Doge) |
|
||||
|
||||
** Navigation
|
||||
| Key | Mode | Action |
|
||||
|--------------+--------+----------------------------------|
|
||||
| =<C-d>= | Normal | Scroll half-page down and center |
|
||||
| =<C-u>= | Normal | Scroll half-page up and center |
|
||||
| =n= | Normal | Next search result (centered) |
|
||||
| =N= | Normal | Previous search result (centered)|
|
||||
| =<C-j>= | Normal | Next location list item |
|
||||
| =<C-k>= | Normal | Previous location list item |
|
||||
| =<leader>k= | Normal | Next location list (centered) |
|
||||
| =<leader>j= | Normal | Previous location list (centered)|
|
||||
| =<leader>cl= | Normal | Close location list |
|
||||
|
||||
** FZF
|
||||
| Key | Mode | Action |
|
||||
|--------------+--------+-------------------------------------|
|
||||
| =<leader>ff= | Normal | Find files |
|
||||
| =<leader>fo= | Normal | File history |
|
||||
| =<leader>fb= | Normal | Open buffers |
|
||||
| =<leader>fq= | Normal | Quickfix list |
|
||||
| =<leader>fh= | Normal | Help tags |
|
||||
| =<leader>fs= | Normal | Grep current word under cursor |
|
||||
| =<leader>fg= | Normal | Grep (prompt for input) |
|
||||
| =<leader>fc= | Normal | Grep for current filename |
|
||||
| =<leader>fi= | Normal | Find files in =~/.vim= config |
|
||||
|
||||
** Clipboard (OSCYank)
|
||||
| Key | Mode | Action |
|
||||
|-------------+---------------+---------------------------|
|
||||
| =<leader>y= | Normal/Visual | Yank via OSCYank |
|
||||
|
||||
* Dependencies
|
||||
|
||||
** Required
|
||||
- =git= - For plugin management
|
||||
- =vim= - 8.0+ recommended
|
||||
- =ripgrep= (=rg=) - Fast grep alternative for FZF
|
||||
- =fd= - Fast find alternative for FZF
|
||||
- =fzf= - Fuzzy finder
|
||||
|
||||
** Optional
|
||||
- =rust-analyzer= - Rust LSP server
|
||||
- =typescript-language-server= - TypeScript/JavaScript LSP
|
||||
- =intelephense= - PHP LSP
|
||||
|
||||
** Installation
|
||||
|
||||
*** macOS
|
||||
#+begin_src bash
|
||||
brew install git vim ripgrep fd fzf
|
||||
brew install rust-analyzer # optional
|
||||
npm install -g typescript-language-server # optional
|
||||
#+end_src
|
||||
|
||||
*** Linux (Debian/Ubuntu)
|
||||
#+begin_src bash
|
||||
sudo apt install git vim ripgrep fd-find fzf
|
||||
# Note: fd is called fd-find on Debian/Ubuntu
|
||||
#+end_src
|
||||
|
||||
*** Rust Analyzer
|
||||
#+begin_src bash
|
||||
rustup component add rust-analyzer
|
||||
#+end_src
|
||||
|
||||
* Setup
|
||||
|
||||
** 1. Clone or copy your Vim configuration
|
||||
#+begin_src bash
|
||||
git clone <your-repo> ~/.vim
|
||||
#+end_src
|
||||
|
||||
** 2. Configure Bash/Zsh
|
||||
Add to =~/.bashrc= or =~/.zshrc=:
|
||||
|
||||
#+begin_src bash
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow'
|
||||
#+end_src
|
||||
|
||||
Then source your shell config:
|
||||
#+begin_src bash
|
||||
source ~/.bashrc # or ~/.zshrc
|
||||
#+end_src
|
||||
|
||||
** 3. Configure fd ignore file
|
||||
Create =~/.fdignore=:
|
||||
|
||||
#+begin_src bash
|
||||
vim ~/.fdignore
|
||||
#+end_src
|
||||
|
||||
Add these lines:
|
||||
#+begin_src
|
||||
undodir/
|
||||
plugged/
|
||||
.git
|
||||
#+end_src
|
||||
|
||||
** 4. Configure ripgrep ignore file
|
||||
Create =~/.rgignore=:
|
||||
|
||||
#+begin_src bash
|
||||
vim ~/.rgignore
|
||||
#+end_src
|
||||
|
||||
Add the same patterns:
|
||||
#+begin_src
|
||||
undodir/
|
||||
plugged/
|
||||
.git
|
||||
#+end_src
|
||||
|
||||
** 5. Install plugins
|
||||
Open Vim and the plugins will auto-install on first run.
|
||||
|
||||
* Plugin List
|
||||
|
||||
| Plugin | Purpose |
|
||||
|-------------------------+-----------------------------------|
|
||||
| =junegunn/fzf= | Fuzzy finder |
|
||||
| =junegunn/fzf.vim= | FZF Vim integration |
|
||||
| =tomasiser/vim-code-dark= | Code Dark color scheme |
|
||||
| =ghifarit53/tokyonight-vim= | Tokyo Night color scheme |
|
||||
| =yegappan/lsp= | LSP client |
|
||||
| =ojroques/vim-oscyank= | Copy to system clipboard via OSC52|
|
||||
| =tpope/vim-commentary= | Comment/uncomment code |
|
||||
| =itchyny/lightline.vim= | Statusline |
|
||||
|
||||
* File Structure
|
||||
|
||||
#+begin_example
|
||||
~/.vim/
|
||||
├── vimrc # Main config (sources all below)
|
||||
├── options.vim # Vim options and settings
|
||||
├── keybinds.vim # Keybindings
|
||||
├── plugins.vim # Plugin manager and plugin list
|
||||
├── colors.vim # Color scheme configuration
|
||||
├── fzf.vim # FZF configuration
|
||||
├── lightline.vim # Lightline configuration
|
||||
└── plugged/ # Plugin installation directory
|
||||
#+end_example
|
||||
|
||||
* Usage
|
||||
|
||||
** Installing Plugins
|
||||
Plugins auto-install when you first start Vim. To manually reinstall, delete =~/.vim/plugged= and restart Vim.
|
||||
|
||||
** Updating Plugins
|
||||
#+begin_src bash
|
||||
cd ~/.vim/plugged/<plugin-name>
|
||||
git pull
|
||||
#+end_src
|
||||
|
||||
** FZF File Search
|
||||
The FZF configuration respects =.gitignore=, =.fdignore=, and =.rgignore= files automatically.
|
||||
|
||||
Use =<leader>ff= to search files, =<leader>fg= to grep content.
|
||||
|
||||
** LSP Servers
|
||||
Configure LSP servers in your config. Currently configured:
|
||||
- Rust: =rust-analyzer=
|
||||
- TypeScript/JavaScript: =typescript-language-server=
|
||||
- PHP: =intelephense=
|
||||
|
||||
* Notes
|
||||
|
||||
- The plugin manager is custom and minimal - it auto-installs plugins on Vim startup
|
||||
- =.fdignore= and =.rgignore= prevent searching through plugin directories and undo files
|
||||
- FZF uses =fd= for file listing (faster than =find=) and =rg= for content search
|
||||
- OSCYank allows copying to system clipboard even over SSH
|
||||
7
vimrc
Normal file
7
vimrc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
source ~/.vim/options.vim
|
||||
source ~/.vim/keybinds.vim
|
||||
source ~/.vim/plugins.vim
|
||||
source ~/.vim/colors.vim
|
||||
source ~/.vim/fzf.vim
|
||||
source ~/.vim/lightline.vim
|
||||
source ~/.vim/lsp.vim
|
||||
Loading…
Add table
Add a link
Reference in a new issue