mirror of
https://github.com/m1ngsama/chopsticks.git
synced 2026-02-08 06:54:05 +00:00
Merge pull request #1 from m1ngsama/claude/vim-config-setup-siZCJ
This commit is contained in:
commit
ff27025cbb
17 changed files with 957 additions and 1348 deletions
647
.vimrc
Normal file
647
.vimrc
Normal file
|
|
@ -0,0 +1,647 @@
|
|||
" ============================================================================
|
||||
" Vim Configuration - The Ultimate vimrc
|
||||
" Inspired by the best practices from the Vim community
|
||||
" ============================================================================
|
||||
|
||||
" ============================================================================
|
||||
" => General Settings
|
||||
" ============================================================================
|
||||
|
||||
" Disable compatibility with vi which can cause unexpected issues
|
||||
set nocompatible
|
||||
|
||||
" Enable type file detection. Vim will be able to try to detect the type of file in use
|
||||
filetype on
|
||||
|
||||
" Enable plugins and load plugin for the detected file type
|
||||
filetype plugin on
|
||||
|
||||
" Load an indent file for the detected file type
|
||||
filetype indent on
|
||||
|
||||
" Turn syntax highlighting on
|
||||
syntax on
|
||||
|
||||
" Add numbers to each line on the left-hand side
|
||||
set number
|
||||
|
||||
" Show relative line numbers
|
||||
set relativenumber
|
||||
|
||||
" Highlight cursor line underneath the cursor horizontally
|
||||
set cursorline
|
||||
|
||||
" Set shift width to 4 spaces
|
||||
set shiftwidth=4
|
||||
|
||||
" Set tab width to 4 columns
|
||||
set tabstop=4
|
||||
|
||||
" Use space characters instead of tabs
|
||||
set expandtab
|
||||
|
||||
" Do not save backup files
|
||||
set nobackup
|
||||
|
||||
" Do not let cursor scroll below or above N number of lines when scrolling
|
||||
set scrolloff=10
|
||||
|
||||
" Do not wrap lines. Allow long lines to extend as far as the line goes
|
||||
set nowrap
|
||||
|
||||
" While searching though a file incrementally highlight matching characters as you type
|
||||
set incsearch
|
||||
|
||||
" Ignore capital letters during search
|
||||
set ignorecase
|
||||
|
||||
" Override the ignorecase option if searching for capital letters
|
||||
set smartcase
|
||||
|
||||
" Show partial command you type in the last line of the screen
|
||||
set showcmd
|
||||
|
||||
" Show the mode you are on the last line
|
||||
set showmode
|
||||
|
||||
" Show matching words during a search
|
||||
set showmatch
|
||||
|
||||
" Use highlighting when doing a search
|
||||
set hlsearch
|
||||
|
||||
" Set the commands to save in history default number is 20
|
||||
set history=1000
|
||||
|
||||
" Enable auto completion menu after pressing TAB
|
||||
set wildmenu
|
||||
|
||||
" Make wildmenu behave like similar to Bash completion
|
||||
set wildmode=list:longest
|
||||
|
||||
" There are certain files that we would never want to edit with Vim
|
||||
" Wildmenu will ignore files with these extensions
|
||||
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
|
||||
|
||||
" Enable mouse support
|
||||
set mouse=a
|
||||
|
||||
" Set encoding
|
||||
set encoding=utf-8
|
||||
|
||||
" Better command-line completion
|
||||
set wildmenu
|
||||
|
||||
" Show cursor position
|
||||
set ruler
|
||||
|
||||
" Display line numbers
|
||||
set number
|
||||
|
||||
" Enable folding
|
||||
set foldmethod=indent
|
||||
set foldlevel=99
|
||||
|
||||
" Split window settings
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
" Better backspace behavior
|
||||
set backspace=indent,eol,start
|
||||
|
||||
" Auto read when file is changed from outside
|
||||
set autoread
|
||||
|
||||
" Turn on the Wild menu for command completion
|
||||
set wildmenu
|
||||
|
||||
" Ignore compiled files
|
||||
set wildignore=*.o,*~,*.pyc
|
||||
if has("win16") || has("win32")
|
||||
set wildignore+=.git\*,.hg\*,.svn\*
|
||||
else
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
||||
endif
|
||||
|
||||
" Always show current position
|
||||
set ruler
|
||||
|
||||
" Height of the command bar
|
||||
set cmdheight=1
|
||||
|
||||
" A buffer becomes hidden when it is abandoned
|
||||
set hid
|
||||
|
||||
" Configure backspace so it acts as it should act
|
||||
set backspace=eol,start,indent
|
||||
set whichwrap+=<,>,h,l
|
||||
|
||||
" Ignore case when searching
|
||||
set ignorecase
|
||||
|
||||
" When searching try to be smart about cases
|
||||
set smartcase
|
||||
|
||||
" Highlight search results
|
||||
set hlsearch
|
||||
|
||||
" Makes search act like search in modern browsers
|
||||
set incsearch
|
||||
|
||||
" Don't redraw while executing macros (good performance config)
|
||||
set lazyredraw
|
||||
|
||||
" For regular expressions turn magic on
|
||||
set magic
|
||||
|
||||
" Show matching brackets when text indicator is over them
|
||||
set showmatch
|
||||
|
||||
" How many tenths of a second to blink when matching brackets
|
||||
set mat=2
|
||||
|
||||
" No annoying sound on errors
|
||||
set noerrorbells
|
||||
set novisualbell
|
||||
set t_vb=
|
||||
set tm=500
|
||||
|
||||
" Enable 256 colors palette in Gnome Terminal
|
||||
if $COLORTERM == 'gnome-terminal'
|
||||
set t_Co=256
|
||||
endif
|
||||
|
||||
" Set extra options when running in GUI mode
|
||||
if has("gui_running")
|
||||
set guioptions-=T
|
||||
set guioptions-=e
|
||||
set t_Co=256
|
||||
set guitablabel=%M\ %t
|
||||
endif
|
||||
|
||||
" Use Unix as the standard file type
|
||||
set ffs=unix,dos,mac
|
||||
|
||||
" Turn backup off, since most stuff is in SVN, git etc. anyway
|
||||
set nobackup
|
||||
set nowb
|
||||
set noswapfile
|
||||
|
||||
" ============================================================================
|
||||
" => Vim-Plug Plugin Manager
|
||||
" ============================================================================
|
||||
|
||||
" Auto-install vim-plug
|
||||
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
|
||||
if empty(glob(data_dir . '/autoload/plug.vim'))
|
||||
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||||
endif
|
||||
|
||||
" Plugin list
|
||||
call plug#begin('~/.vim/plugged')
|
||||
|
||||
" ===== File Navigation & Search =====
|
||||
Plug 'preservim/nerdtree' " File explorer
|
||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
||||
Plug 'junegunn/fzf.vim' " Fuzzy finder
|
||||
Plug 'ctrlpvim/ctrlp.vim' " Fuzzy file finder
|
||||
|
||||
" ===== Git Integration =====
|
||||
Plug 'tpope/vim-fugitive' " Git wrapper
|
||||
Plug 'airblade/vim-gitgutter' " Show git diff in gutter
|
||||
|
||||
" ===== Status Line & UI =====
|
||||
Plug 'vim-airline/vim-airline' " Status bar
|
||||
Plug 'vim-airline/vim-airline-themes' " Airline themes
|
||||
|
||||
" ===== Code Editing & Completion =====
|
||||
Plug 'tpope/vim-surround' " Surround text objects
|
||||
Plug 'tpope/vim-commentary' " Comment stuff out
|
||||
Plug 'tpope/vim-repeat' " Repeat plugin maps
|
||||
Plug 'jiangmiao/auto-pairs' " Auto close brackets
|
||||
Plug 'dense-analysis/ale' " Async linting engine
|
||||
|
||||
" ===== Language Support =====
|
||||
Plug 'sheerun/vim-polyglot' " Language pack
|
||||
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " Go support
|
||||
|
||||
" ===== Color Schemes =====
|
||||
Plug 'morhetz/gruvbox' " Gruvbox theme
|
||||
Plug 'dracula/vim', { 'as': 'dracula' } " Dracula theme
|
||||
Plug 'altercation/vim-colors-solarized' " Solarized theme
|
||||
Plug 'joshdick/onedark.vim' " One Dark theme
|
||||
|
||||
" ===== Productivity =====
|
||||
Plug 'mbbill/undotree' " Undo history visualizer
|
||||
Plug 'preservim/tagbar' " Tag browser
|
||||
Plug 'easymotion/vim-easymotion' " Easy motion
|
||||
|
||||
" ===== Code Intelligence =====
|
||||
if has('vim9') || has('nvim')
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'} " LSP & Completion
|
||||
endif
|
||||
|
||||
call plug#end()
|
||||
|
||||
" ============================================================================
|
||||
" => Colors and Fonts
|
||||
" ============================================================================
|
||||
|
||||
" Enable true colors support
|
||||
if has('termguicolors')
|
||||
set termguicolors
|
||||
endif
|
||||
|
||||
" Set colorscheme
|
||||
try
|
||||
colorscheme gruvbox
|
||||
set background=dark
|
||||
catch
|
||||
colorscheme desert
|
||||
endtry
|
||||
|
||||
" Set font for GUI
|
||||
if has("gui_running")
|
||||
if has("gui_gtk2") || has("gui_gtk3")
|
||||
set guifont=Hack\ 12,Source\ Code\ Pro\ 12,Monospace\ 12
|
||||
elseif has("gui_win32")
|
||||
set guifont=Consolas:h11:cANSI
|
||||
endif
|
||||
endif
|
||||
|
||||
" ============================================================================
|
||||
" => Text, Tab and Indent Related
|
||||
" ============================================================================
|
||||
|
||||
" Use spaces instead of tabs
|
||||
set expandtab
|
||||
|
||||
" Be smart when using tabs
|
||||
set smarttab
|
||||
|
||||
" 1 tab == 4 spaces
|
||||
set shiftwidth=4
|
||||
set tabstop=4
|
||||
|
||||
" Linebreak on 500 characters
|
||||
set lbr
|
||||
set tw=500
|
||||
|
||||
set ai "Auto indent
|
||||
set si "Smart indent
|
||||
set wrap "Wrap lines
|
||||
|
||||
" ============================================================================
|
||||
" => Key Mappings
|
||||
" ============================================================================
|
||||
|
||||
" Set leader key to comma
|
||||
let mapleader = ","
|
||||
|
||||
" Fast saving
|
||||
nmap <leader>w :w!<cr>
|
||||
|
||||
" Fast quitting
|
||||
nmap <leader>q :q<cr>
|
||||
|
||||
" Fast save and quit
|
||||
nmap <leader>x :x<cr>
|
||||
|
||||
" Disable highlight when <leader><cr> is pressed
|
||||
map <silent> <leader><cr> :noh<cr>
|
||||
|
||||
" Smart way to move between windows
|
||||
map <C-j> <C-W>j
|
||||
map <C-k> <C-W>k
|
||||
map <C-h> <C-W>h
|
||||
map <C-l> <C-W>l
|
||||
|
||||
" Close the current buffer
|
||||
map <leader>bd :Bclose<cr>:tabclose<cr>gT
|
||||
|
||||
" Close all the buffers
|
||||
map <leader>ba :bufdo bd<cr>
|
||||
|
||||
" Next buffer
|
||||
map <leader>l :bnext<cr>
|
||||
|
||||
" Previous buffer
|
||||
map <leader>h :bprevious<cr>
|
||||
|
||||
" Useful mappings for managing tabs
|
||||
map <leader>tn :tabnew<cr>
|
||||
map <leader>to :tabonly<cr>
|
||||
map <leader>tc :tabclose<cr>
|
||||
map <leader>tm :tabmove
|
||||
map <leader>t<leader> :tabnext<cr>
|
||||
|
||||
" Let 'tl' toggle between this and the last accessed tab
|
||||
let g:lasttab = 1
|
||||
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
|
||||
au TabLeave * let g:lasttab = tabpagenr()
|
||||
|
||||
" Opens a new tab with the current buffer's path
|
||||
map <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/
|
||||
|
||||
" Switch CWD to the directory of the open buffer
|
||||
map <leader>cd :cd %:p:h<cr>:pwd<cr>
|
||||
|
||||
" Remap VIM 0 to first non-blank character
|
||||
map 0 ^
|
||||
|
||||
" Move a line of text using ALT+[jk] or Command+[jk] on mac
|
||||
nmap <M-j> mz:m+<cr>`z
|
||||
nmap <M-k> mz:m-2<cr>`z
|
||||
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
|
||||
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
|
||||
|
||||
" Pressing ,ss will toggle and untoggle spell checking
|
||||
map <leader>ss :setlocal spell!<cr>
|
||||
|
||||
" Shortcuts using <leader>
|
||||
map <leader>sn ]s
|
||||
map <leader>sp [s
|
||||
map <leader>sa zg
|
||||
map <leader>s? z=
|
||||
|
||||
" Remove trailing whitespace
|
||||
nnoremap <leader>w :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
|
||||
|
||||
" Toggle paste mode
|
||||
set pastetoggle=<F2>
|
||||
|
||||
" Toggle line numbers
|
||||
nnoremap <F3> :set invnumber<CR>
|
||||
|
||||
" Toggle relative line numbers
|
||||
nnoremap <F4> :set invrelativenumber<CR>
|
||||
|
||||
" Enable folding with the spacebar
|
||||
nnoremap <space> za
|
||||
|
||||
" ============================================================================
|
||||
" => Plugin Settings
|
||||
" ============================================================================
|
||||
|
||||
" --- NERDTree ---
|
||||
map <C-n> :NERDTreeToggle<CR>
|
||||
map <leader>n :NERDTreeFind<CR>
|
||||
|
||||
" Close vim if the only window left open is a NERDTree
|
||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
||||
|
||||
" Show hidden files
|
||||
let NERDTreeShowHidden=1
|
||||
|
||||
" Ignore files in NERDTree
|
||||
let NERDTreeIgnore=['\.pyc$', '\~$', '\.swp$', '\.git$', '\.DS_Store']
|
||||
|
||||
" --- FZF ---
|
||||
map <C-p> :Files<CR>
|
||||
map <leader>b :Buffers<CR>
|
||||
map <leader>rg :Rg<CR>
|
||||
map <leader>t :Tags<CR>
|
||||
|
||||
" --- CtrlP ---
|
||||
let g:ctrlp_working_path_mode = 'ra'
|
||||
let g:ctrlp_show_hidden = 1
|
||||
let g:ctrlp_custom_ignore = {
|
||||
\ 'dir': '\v[\/]\.(git|hg|svn)$',
|
||||
\ 'file': '\v\.(exe|so|dll|pyc)$',
|
||||
\ }
|
||||
|
||||
" --- Airline ---
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
let g:airline#extensions#tabline#left_sep = ' '
|
||||
let g:airline#extensions#tabline#left_alt_sep = '|'
|
||||
let g:airline#extensions#tabline#formatter = 'unique_tail'
|
||||
let g:airline_powerline_fonts = 1
|
||||
let g:airline_theme='gruvbox'
|
||||
|
||||
" --- GitGutter ---
|
||||
let g:gitgutter_sign_added = '+'
|
||||
let g:gitgutter_sign_modified = '~'
|
||||
let g:gitgutter_sign_removed = '-'
|
||||
let g:gitgutter_sign_removed_first_line = '^'
|
||||
let g:gitgutter_sign_modified_removed = '~'
|
||||
|
||||
" --- ALE (Asynchronous Lint Engine) ---
|
||||
let g:ale_linters = {
|
||||
\ 'python': ['flake8', 'pylint'],
|
||||
\ 'javascript': ['eslint'],
|
||||
\ 'go': ['gopls', 'golint'],
|
||||
\}
|
||||
|
||||
let g:ale_fixers = {
|
||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||
\ 'python': ['black', 'isort'],
|
||||
\ 'javascript': ['prettier', 'eslint'],
|
||||
\ 'go': ['gofmt', 'goimports'],
|
||||
\}
|
||||
|
||||
let g:ale_fix_on_save = 1
|
||||
let g:ale_sign_error = '✗'
|
||||
let g:ale_sign_warning = '⚠'
|
||||
|
||||
" Navigate between errors
|
||||
nmap <silent> <leader>aj :ALENext<cr>
|
||||
nmap <silent> <leader>ak :ALEPrevious<cr>
|
||||
|
||||
" --- Tagbar ---
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
|
||||
" --- UndoTree ---
|
||||
nnoremap <F5> :UndotreeToggle<CR>
|
||||
|
||||
" --- EasyMotion ---
|
||||
let g:EasyMotion_do_mapping = 0 " Disable default mappings
|
||||
|
||||
" Jump to anywhere you want with minimal keystrokes
|
||||
nmap s <Plug>(easymotion-overwin-f2)
|
||||
|
||||
" Turn on case-insensitive feature
|
||||
let g:EasyMotion_smartcase = 1
|
||||
|
||||
" JK motions: Line motions
|
||||
map <Leader>j <Plug>(easymotion-j)
|
||||
map <Leader>k <Plug>(easymotion-k)
|
||||
|
||||
" --- CoC (Conquer of Completion) ---
|
||||
if exists('g:plugs["coc.nvim"]')
|
||||
" Use tab for trigger completion with characters ahead and navigate
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ coc#pum#visible() ? coc#pum#next(1) :
|
||||
\ CheckBackspace() ? "\<Tab>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
|
||||
|
||||
" Make <CR> to accept selected completion item
|
||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
function! CheckBackspace() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
" Use <c-space> to trigger completion
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" GoTo code navigation
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window
|
||||
nnoremap <silent> K :call ShowDocumentation()<CR>
|
||||
|
||||
function! ShowDocumentation()
|
||||
if CocAction('hasProvider', 'hover')
|
||||
call CocActionAsync('doHover')
|
||||
else
|
||||
call feedkeys('K', 'in')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Highlight the symbol and its references when holding the cursor
|
||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Symbol renaming
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Formatting selected code
|
||||
xmap <leader>f <Plug>(coc-format-selected)
|
||||
nmap <leader>f <Plug>(coc-format-selected)
|
||||
endif
|
||||
|
||||
" ============================================================================
|
||||
" => Helper Functions
|
||||
" ============================================================================
|
||||
|
||||
" Returns true if paste mode is enabled
|
||||
function! HasPaste()
|
||||
if &paste
|
||||
return 'PASTE MODE '
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Don't close window, when deleting a buffer
|
||||
command! Bclose call <SID>BufcloseCloseIt()
|
||||
function! <SID>BufcloseCloseIt()
|
||||
let l:currentBufNum = bufnr("%")
|
||||
let l:alternateBufNum = bufnr("#")
|
||||
|
||||
if buflisted(l:alternateBufNum)
|
||||
buffer #
|
||||
else
|
||||
bnext
|
||||
endif
|
||||
|
||||
if bufnr("%") == l:currentBufNum
|
||||
new
|
||||
endif
|
||||
|
||||
if buflisted(l:currentBufNum)
|
||||
execute("bdelete! ".l:currentBufNum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Delete trailing white space on save
|
||||
fun! CleanExtraSpaces()
|
||||
let save_cursor = getpos(".")
|
||||
let old_query = getreg('/')
|
||||
silent! %s/\s\+$//e
|
||||
call setpos('.', save_cursor)
|
||||
call setreg('/', old_query)
|
||||
endfun
|
||||
|
||||
if has("autocmd")
|
||||
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
|
||||
endif
|
||||
|
||||
" ============================================================================
|
||||
" => Auto Commands
|
||||
" ============================================================================
|
||||
|
||||
" Return to last edit position when opening files
|
||||
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
|
||||
" Set specific file types
|
||||
autocmd BufNewFile,BufRead *.json setlocal filetype=json
|
||||
autocmd BufNewFile,BufRead *.md setlocal filetype=markdown
|
||||
autocmd BufNewFile,BufRead *.jsx setlocal filetype=javascript.jsx
|
||||
autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx
|
||||
|
||||
" Python specific settings
|
||||
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=4 colorcolumn=88
|
||||
|
||||
" JavaScript specific settings
|
||||
autocmd FileType javascript,typescript setlocal expandtab shiftwidth=2 tabstop=2
|
||||
|
||||
" Go specific settings
|
||||
autocmd FileType go setlocal noexpandtab shiftwidth=4 tabstop=4
|
||||
|
||||
" ============================================================================
|
||||
" => Status Line
|
||||
" ============================================================================
|
||||
|
||||
" Always show the status line
|
||||
set laststatus=2
|
||||
|
||||
" Format the status line (if not using airline)
|
||||
" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
|
||||
|
||||
" ============================================================================
|
||||
" => Misc
|
||||
" ============================================================================
|
||||
|
||||
" Quickly open a buffer for scribble
|
||||
map <leader>q :e ~/buffer<cr>
|
||||
|
||||
" Quickly open a markdown buffer for scribble
|
||||
map <leader>m :e ~/buffer.md<cr>
|
||||
|
||||
" Toggle between number and relativenumber
|
||||
function! ToggleNumber()
|
||||
if(&relativenumber == 1)
|
||||
set norelativenumber
|
||||
set number
|
||||
else
|
||||
set relativenumber
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Toggle paste mode
|
||||
map <leader>pp :setlocal paste!<cr>
|
||||
|
||||
" ============================================================================
|
||||
" => Performance Optimization
|
||||
" ============================================================================
|
||||
|
||||
" Optimize for large files
|
||||
set synmaxcol=200
|
||||
set ttyfast
|
||||
|
||||
" Reduce updatetime for better user experience
|
||||
set updatetime=300
|
||||
|
||||
" Don't pass messages to |ins-completion-menu|
|
||||
set shortmess+=c
|
||||
|
||||
" Always show the signcolumn
|
||||
if has("patch-8.1.1564")
|
||||
set signcolumn=number
|
||||
else
|
||||
set signcolumn=yes
|
||||
endif
|
||||
|
||||
" ============================================================================
|
||||
" End of Configuration
|
||||
" ============================================================================
|
||||
311
README.md
311
README.md
|
|
@ -1,2 +1,311 @@
|
|||
m1ngsama's neovim config
|
||||
# The Ultimate Vim Configuration
|
||||
|
||||
A comprehensive, modern Vim configuration inspired by the best practices from the Vim community. This configuration transforms vanilla Vim into a powerful, feature-rich development environment.
|
||||
|
||||
## Features
|
||||
|
||||
### Core Enhancements
|
||||
- **Smart Line Numbers**: Hybrid line numbers (absolute + relative) for efficient navigation
|
||||
- **Modern UI**: Gruvbox color scheme with airline status bar
|
||||
- **Plugin Management**: vim-plug for easy plugin installation and updates
|
||||
- **Auto-completion**: CoC (Conquer of Completion) for intelligent code completion
|
||||
- **Syntax Checking**: ALE (Asynchronous Lint Engine) for real-time linting
|
||||
|
||||
### File Navigation
|
||||
- **NERDTree**: Visual file explorer (`Ctrl+n`)
|
||||
- **FZF**: Blazing fast fuzzy finder (`Ctrl+p`)
|
||||
- **CtrlP**: Alternative fuzzy file finder
|
||||
- **Easy Motion**: Jump to any location with minimal keystrokes
|
||||
|
||||
### Git Integration
|
||||
- **Fugitive**: Complete Git wrapper for Vim
|
||||
- **GitGutter**: Show git diff in the sign column
|
||||
|
||||
### Code Editing
|
||||
- **Auto-pairs**: Automatic bracket/quote pairing
|
||||
- **Surround**: Easily change surrounding quotes, brackets, tags
|
||||
- **Commentary**: Quick code commenting (`gc`)
|
||||
- **Multi-language Support**: vim-polyglot for 100+ languages
|
||||
|
||||
### Productivity Tools
|
||||
- **UndoTree**: Visualize and navigate undo history (`F5`)
|
||||
- **Tagbar**: Code structure browser (`F8`)
|
||||
- **Smart Window Management**: Easy navigation with `Ctrl+hjkl`
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Clone this repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim
|
||||
cd ~/.vim
|
||||
```
|
||||
|
||||
### 2. Create symlink to .vimrc
|
||||
|
||||
```bash
|
||||
ln -s ~/.vim/.vimrc ~/.vimrc
|
||||
```
|
||||
|
||||
### 3. Install vim-plug and plugins
|
||||
|
||||
Open Vim and the plugins will be automatically installed:
|
||||
|
||||
```bash
|
||||
vim
|
||||
```
|
||||
|
||||
Or manually install plugins:
|
||||
|
||||
```vim
|
||||
:PlugInstall
|
||||
```
|
||||
|
||||
### 4. (Optional) Install recommended dependencies
|
||||
|
||||
For the best experience, install these optional dependencies:
|
||||
|
||||
```bash
|
||||
# FZF (fuzzy finder)
|
||||
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
||||
~/.fzf/install
|
||||
|
||||
# ripgrep (better grep)
|
||||
# On Ubuntu/Debian
|
||||
sudo apt install ripgrep
|
||||
|
||||
# On macOS
|
||||
brew install ripgrep
|
||||
|
||||
# Node.js (for CoC)
|
||||
# Required for code completion
|
||||
curl -sL install-node.now.sh/lts | bash
|
||||
|
||||
# Universal Ctags (for Tagbar)
|
||||
# On Ubuntu/Debian
|
||||
sudo apt install universal-ctags
|
||||
|
||||
# On macOS
|
||||
brew install universal-ctags
|
||||
```
|
||||
|
||||
### 5. Install CoC language servers
|
||||
|
||||
For intelligent code completion, install language servers:
|
||||
|
||||
```vim
|
||||
" Python
|
||||
:CocInstall coc-pyright
|
||||
|
||||
" JavaScript/TypeScript
|
||||
:CocInstall coc-tsserver
|
||||
|
||||
" Go
|
||||
:CocInstall coc-go
|
||||
|
||||
" JSON
|
||||
:CocInstall coc-json
|
||||
|
||||
" HTML/CSS
|
||||
:CocInstall coc-html coc-css
|
||||
|
||||
" See more: https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions
|
||||
```
|
||||
|
||||
## Key Mappings
|
||||
|
||||
### General
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `,w` | Quick save |
|
||||
| `,q` | Quick quit |
|
||||
| `,x` | Save and quit |
|
||||
| `,,` + Enter | Clear search highlight |
|
||||
|
||||
### Window Navigation
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Ctrl+h` | Move to left window |
|
||||
| `Ctrl+j` | Move to bottom window |
|
||||
| `Ctrl+k` | Move to top window |
|
||||
| `Ctrl+l` | Move to right window |
|
||||
|
||||
### Buffer Management
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `,l` | Next buffer |
|
||||
| `,h` | Previous buffer |
|
||||
| `,bd` | Close current buffer |
|
||||
| `,ba` | Close all buffers |
|
||||
|
||||
### Tab Management
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `,tn` | New tab |
|
||||
| `,tc` | Close tab |
|
||||
| `,tl` | Toggle to last tab |
|
||||
|
||||
### File Navigation
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Ctrl+n` | Toggle NERDTree |
|
||||
| `,n` | Find current file in NERDTree |
|
||||
| `Ctrl+p` | FZF file search |
|
||||
| `,b` | FZF buffer search |
|
||||
| `,rg` | Ripgrep search |
|
||||
|
||||
### Code Navigation (CoC)
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `gd` | Go to definition |
|
||||
| `gy` | Go to type definition |
|
||||
| `gi` | Go to implementation |
|
||||
| `gr` | Go to references |
|
||||
| `K` | Show documentation |
|
||||
| `[g` | Previous diagnostic |
|
||||
| `]g` | Next diagnostic |
|
||||
| `,rn` | Rename symbol |
|
||||
|
||||
### Linting (ALE)
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `,aj` | Next error/warning |
|
||||
| `,ak` | Previous error/warning |
|
||||
|
||||
### Other Utilities
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `F2` | Toggle paste mode |
|
||||
| `F3` | Toggle line numbers |
|
||||
| `F4` | Toggle relative numbers |
|
||||
| `F5` | Toggle UndoTree |
|
||||
| `F8` | Toggle Tagbar |
|
||||
| `Space` | Toggle fold |
|
||||
| `s` + 2 chars | EasyMotion jump |
|
||||
|
||||
## Plugin List
|
||||
|
||||
### File Navigation & Search
|
||||
- **NERDTree**: File system explorer
|
||||
- **FZF**: Fuzzy file finder
|
||||
- **CtrlP**: Alternative fuzzy finder
|
||||
|
||||
### Git
|
||||
- **vim-fugitive**: Git integration
|
||||
- **vim-gitgutter**: Git diff in sign column
|
||||
|
||||
### UI
|
||||
- **vim-airline**: Enhanced status line
|
||||
- **gruvbox**: Color scheme
|
||||
|
||||
### Code Editing
|
||||
- **vim-surround**: Manage surroundings
|
||||
- **vim-commentary**: Code commenting
|
||||
- **auto-pairs**: Auto close brackets
|
||||
- **ALE**: Asynchronous linting
|
||||
|
||||
### Language Support
|
||||
- **vim-polyglot**: Language pack for 100+ languages
|
||||
- **vim-go**: Go development
|
||||
|
||||
### Productivity
|
||||
- **UndoTree**: Undo history visualizer
|
||||
- **Tagbar**: Code structure browser
|
||||
- **EasyMotion**: Fast cursor movement
|
||||
- **CoC**: Code completion and LSP
|
||||
|
||||
## Color Schemes
|
||||
|
||||
Available color schemes (change in .vimrc):
|
||||
|
||||
- **gruvbox** (default) - Warm, retro groove colors
|
||||
- **dracula** - Dark theme with vivid colors
|
||||
- **solarized** - Precision colors for machines and people
|
||||
- **onedark** - Atom's iconic One Dark theme
|
||||
|
||||
To change:
|
||||
|
||||
```vim
|
||||
colorscheme dracula
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
The configuration is organized into sections:
|
||||
|
||||
1. **General Settings**: Basic Vim behavior
|
||||
2. **Plugin Management**: vim-plug configuration
|
||||
3. **Colors & Fonts**: Visual appearance
|
||||
4. **Key Mappings**: Custom keybindings
|
||||
5. **Plugin Settings**: Individual plugin configurations
|
||||
6. **Auto Commands**: File-type specific settings
|
||||
7. **Helper Functions**: Utility functions
|
||||
|
||||
Feel free to modify any section to suit your needs!
|
||||
|
||||
## Language-Specific Settings
|
||||
|
||||
### Python
|
||||
- 4 spaces indentation
|
||||
- 88 character line limit (Black formatter)
|
||||
- Auto-formatting with Black on save
|
||||
|
||||
### JavaScript/TypeScript
|
||||
- 2 spaces indentation
|
||||
- Prettier formatting on save
|
||||
- ESLint integration
|
||||
|
||||
### Go
|
||||
- Tab indentation
|
||||
- Auto-formatting with gofmt
|
||||
- Auto-import with goimports
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Plugins not working
|
||||
|
||||
```vim
|
||||
:PlugInstall
|
||||
:PlugUpdate
|
||||
```
|
||||
|
||||
### CoC not working
|
||||
|
||||
Make sure Node.js is installed:
|
||||
|
||||
```bash
|
||||
node --version # Should be >= 14.14
|
||||
```
|
||||
|
||||
### Colors look wrong
|
||||
|
||||
Enable true colors in your terminal emulator and add to your shell rc:
|
||||
|
||||
```bash
|
||||
export TERM=xterm-256color
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
This configuration is inspired by:
|
||||
|
||||
- [amix/vimrc](https://github.com/amix/vimrc) - The ultimate vimrc
|
||||
- [vim-plug](https://github.com/junegunn/vim-plug) - Minimalist plugin manager
|
||||
- [Top 50 Vim Configuration Options](https://www.shortcutfoo.com/blog/top-50-vim-configuration-options)
|
||||
- [Modern Vim Development Setup 2025](https://swedishembedded.com/developers/vim-in-minutes)
|
||||
|
||||
## License
|
||||
|
||||
MIT License - Feel free to use and modify!
|
||||
|
||||
## Contributing
|
||||
|
||||
Suggestions and improvements are welcome! Feel free to open an issue or submit a pull request.
|
||||
|
|
|
|||
10
init.lua
10
init.lua
|
|
@ -1,10 +0,0 @@
|
|||
if vim.loader then
|
||||
vim.loader.enable()
|
||||
end
|
||||
|
||||
_G.dd = function(...)
|
||||
require("util.debug").dump(...)
|
||||
end
|
||||
vim.print = _G.dd
|
||||
|
||||
require("config.lazy")
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
-- Turn off paste mode when leaving insert
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
pattern = "*",
|
||||
command = "set nopaste",
|
||||
})
|
||||
|
||||
-- Disable the concealing in some file formats
|
||||
-- The default conceallevel is 3 in LazyVim
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "json", "jsonc", "markdown" },
|
||||
callback = function()
|
||||
vim.opt.conceallevel = 0
|
||||
end,
|
||||
})
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
local discipline = require("m1ngsama.discipline")
|
||||
|
||||
-- discipline.cowboy()
|
||||
|
||||
local keymap = vim.keymap
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- Do things without affecting the registers
|
||||
keymap.set("n", "x", '"_x')
|
||||
keymap.set("n", "<Leader>p", '"0p')
|
||||
keymap.set("n", "<Leader>P", '"0P')
|
||||
keymap.set("v", "<Leader>p", '"0p')
|
||||
keymap.set("n", "<Leader>c", '"_c')
|
||||
keymap.set("n", "<Leader>C", '"_C')
|
||||
keymap.set("v", "<Leader>c", '"_c')
|
||||
keymap.set("v", "<Leader>C", '"_C')
|
||||
keymap.set("n", "<Leader>d", '"_d')
|
||||
keymap.set("n", "<Leader>D", '"_D')
|
||||
keymap.set("v", "<Leader>d", '"_d')
|
||||
keymap.set("v", "<Leader>D", '"_D')
|
||||
|
||||
-- Increment/decrement
|
||||
keymap.set("n", "+", "<C-a>")
|
||||
keymap.set("n", "-", "<C-x>")
|
||||
|
||||
-- Delete a word backwards
|
||||
keymap.set("n", "dw", 'vb"_d')
|
||||
|
||||
-- Select all
|
||||
keymap.set("n", "<C-a>", "gg<S-v>G")
|
||||
|
||||
-- Save with root permission (not working for now)
|
||||
--vim.api.nvim_create_user_command('W', 'w !sudo tee > /dev/null %', {})
|
||||
|
||||
-- Disable continuations
|
||||
keymap.set("n", "<Leader>o", "o<Esc>^Da", opts)
|
||||
keymap.set("n", "<Leader>O", "O<Esc>^Da", opts)
|
||||
|
||||
-- Jumplist
|
||||
keymap.set("n", "<C-m>", "<C-i>", opts)
|
||||
|
||||
-- New tab
|
||||
keymap.set("n", "te", ":tabedit")
|
||||
keymap.set("n", "<tab>", ":tabnext<Return>", opts)
|
||||
keymap.set("n", "<s-tab>", ":tabprev<Return>", opts)
|
||||
-- Split window
|
||||
keymap.set("n", "ss", ":split<Return>", opts)
|
||||
keymap.set("n", "sv", ":vsplit<Return>", opts)
|
||||
-- Move window
|
||||
keymap.set("n", "sh", "<C-w>h")
|
||||
keymap.set("n", "sk", "<C-w>k")
|
||||
keymap.set("n", "sj", "<C-w>j")
|
||||
keymap.set("n", "sl", "<C-w>l")
|
||||
|
||||
-- Resize window
|
||||
keymap.set("n", "<C-w><left>", "<C-w><")
|
||||
keymap.set("n", "<C-w><right>", "<C-w>>")
|
||||
keymap.set("n", "<C-w><up>", "<C-w>+")
|
||||
keymap.set("n", "<C-w><down>", "<C-w>-")
|
||||
|
||||
-- Diagnostics
|
||||
keymap.set("n", "<C-j>", function()
|
||||
vim.diagnostic.goto_next()
|
||||
end, opts)
|
||||
|
||||
keymap.set("n", "<leader>r", function()
|
||||
require("m1ngsama.hsl").replaceHexWithHSL()
|
||||
end)
|
||||
|
||||
keymap.set("n", "<leader>i", function()
|
||||
require("m1ngsama.lsp").toggleInlayHints()
|
||||
end)
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
import = "lazyvim.plugins",
|
||||
opts = {
|
||||
colorscheme = "solarized-osaka",
|
||||
news = {
|
||||
lazyvim = true,
|
||||
neovim = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- import any extras modules here
|
||||
{ import = "lazyvim.plugins.extras.linting.eslint" },
|
||||
{ import = "lazyvim.plugins.extras.formatting.prettier" },
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||
-- { import = "lazyvim.plugins.extras.lang.markdown" },
|
||||
{ import = "lazyvim.plugins.extras.lang.rust" },
|
||||
{ import = "lazyvim.plugins.extras.lang.tailwind" },
|
||||
-- { import = "lazyvim.plugins.extras.ai.copilot" },
|
||||
-- { import = "lazyvim.plugins.extras.dap.core" },
|
||||
-- { import = "lazyvim.plugins.extras.vscode" },
|
||||
{ import = "lazyvim.plugins.extras.util.mini-hipatterns" },
|
||||
-- { import = "lazyvim.plugins.extras.test.core" },
|
||||
-- { import = "lazyvim.plugins.extras.coding.yanky" },
|
||||
-- { import = "lazyvim.plugins.extras.editor.mini-files" },
|
||||
-- { import = "lazyvim.plugins.extras.util.project" },
|
||||
{ import = "plugins" },
|
||||
},
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
},
|
||||
dev = {
|
||||
path = "~/.ghq/github.com",
|
||||
},
|
||||
checker = { enabled = true }, -- automatically check for plugin updates
|
||||
performance = {
|
||||
cache = {
|
||||
enabled = true,
|
||||
-- disable_events = {},
|
||||
},
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
"netrwPlugin",
|
||||
"rplugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
ui = {
|
||||
custom_keys = {
|
||||
["<localleader>d"] = function(plugin)
|
||||
dd(plugin)
|
||||
end,
|
||||
},
|
||||
},
|
||||
debug = false,
|
||||
})
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
vim.g.mapleader = " "
|
||||
|
||||
vim.opt.encoding = "utf-8"
|
||||
vim.opt.fileencoding = "utf-8"
|
||||
|
||||
vim.opt.number = true
|
||||
|
||||
vim.opt.title = true
|
||||
vim.opt.autoindent = true
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.hlsearch = true
|
||||
vim.opt.backup = false
|
||||
vim.opt.showcmd = true
|
||||
vim.opt.cmdheight = 1
|
||||
vim.opt.laststatus = 3
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.scrolloff = 10
|
||||
vim.opt.shell = "fish"
|
||||
vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" }
|
||||
vim.opt.inccommand = "split"
|
||||
vim.opt.ignorecase = true -- Case insensitive searching UNLESS /C or capital in search
|
||||
vim.opt.smarttab = true
|
||||
vim.opt.breakindent = true
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.wrap = false -- No Wrap lines
|
||||
vim.opt.backspace = { "start", "eol", "indent" }
|
||||
vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolders
|
||||
vim.opt.wildignore:append({ "*/node_modules/*" })
|
||||
vim.opt.splitbelow = true -- Put new windows below current
|
||||
vim.opt.splitright = true -- Put new windows right of current
|
||||
vim.opt.splitkeep = "cursor"
|
||||
vim.opt.mouse = ""
|
||||
|
||||
-- Undercurl
|
||||
vim.cmd([[let &t_Cs = "\e[4:3m"]])
|
||||
vim.cmd([[let &t_Ce = "\e[4:0m"]])
|
||||
|
||||
-- Add asterisks in block comments
|
||||
vim.opt.formatoptions:append({ "r" })
|
||||
|
||||
vim.cmd([[au BufNewFile,BufRead *.astro setf astro]])
|
||||
vim.cmd([[au BufNewFile,BufRead Podfile setf ruby]])
|
||||
|
||||
if vim.fn.has("nvim-0.8") == 1 then
|
||||
vim.opt.cmdheight = 0
|
||||
end
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
function M.cowboy()
|
||||
---@type table?
|
||||
local ok = true
|
||||
for _, key in ipairs({ "h", "j", "k", "l", "+", "-" }) do
|
||||
local count = 0
|
||||
local timer = assert(vim.uv.new_timer())
|
||||
local map = key
|
||||
vim.keymap.set("n", key, function()
|
||||
if vim.v.count > 0 then
|
||||
count = 0
|
||||
end
|
||||
if count >= 10 and vim.bo.buftype ~= "nofile" then
|
||||
ok = pcall(vim.notify, "Hold it Cowboy!", vim.log.levels.WARN, {
|
||||
icon = "🤠",
|
||||
id = "cowboy",
|
||||
keep = function()
|
||||
return count >= 10
|
||||
end,
|
||||
})
|
||||
if not ok then
|
||||
return map
|
||||
end
|
||||
else
|
||||
count = count + 1
|
||||
timer:start(2000, 0, function()
|
||||
count = 0
|
||||
end)
|
||||
return map
|
||||
end
|
||||
end, { expr = true, silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
-- https://github.com/EmmanuelOga/columns/blob/master/utils/color.lua
|
||||
|
||||
local M = {}
|
||||
|
||||
local hexChars = "0123456789abcdef"
|
||||
|
||||
function M.hex_to_rgb(hex)
|
||||
hex = string.lower(hex)
|
||||
local ret = {}
|
||||
for i = 0, 2 do
|
||||
local char1 = string.sub(hex, i * 2 + 2, i * 2 + 2)
|
||||
local char2 = string.sub(hex, i * 2 + 3, i * 2 + 3)
|
||||
local digit1 = string.find(hexChars, char1) - 1
|
||||
local digit2 = string.find(hexChars, char2) - 1
|
||||
ret[i + 1] = (digit1 * 16 + digit2) / 255.0
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
--[[
|
||||
* Converts an RGB color value to HSL. Conversion formula
|
||||
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
||||
* Assumes r, g, and b are contained in the set [0, 255] and
|
||||
* returns h, s, and l in the set [0, 1].
|
||||
*
|
||||
* @param Number r The red color value
|
||||
* @param Number g The green color value
|
||||
* @param Number b The blue color value
|
||||
* @return Array The HSL representation
|
||||
]]
|
||||
function M.rgbToHsl(r, g, b)
|
||||
local max, min = math.max(r, g, b), math.min(r, g, b)
|
||||
local h = 0
|
||||
local s = 0
|
||||
local l = 0
|
||||
|
||||
l = (max + min) / 2
|
||||
|
||||
if max == min then
|
||||
h, s = 0, 0 -- achromatic
|
||||
else
|
||||
local d = max - min
|
||||
if l > 0.5 then
|
||||
s = d / (2 - max - min)
|
||||
else
|
||||
s = d / (max + min)
|
||||
end
|
||||
if max == r then
|
||||
h = (g - b) / d
|
||||
if g < b then
|
||||
h = h + 6
|
||||
end
|
||||
elseif max == g then
|
||||
h = (b - r) / d + 2
|
||||
elseif max == b then
|
||||
h = (r - g) / d + 4
|
||||
end
|
||||
h = h / 6
|
||||
end
|
||||
|
||||
return h * 360, s * 100, l * 100
|
||||
end
|
||||
|
||||
--[[
|
||||
* Converts an HSL color value to RGB. Conversion formula
|
||||
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
||||
* Assumes h, s, and l are contained in the set [0, 1] and
|
||||
* returns r, g, and b in the set [0, 255].
|
||||
*
|
||||
* @param Number h The hue
|
||||
* @param Number s The saturation
|
||||
* @param Number l The lightness
|
||||
* @return Array The RGB representation
|
||||
]]
|
||||
function M.hslToRgb(h, s, l)
|
||||
local r, g, b
|
||||
|
||||
if s == 0 then
|
||||
r, g, b = l, l, l -- achromatic
|
||||
else
|
||||
function hue2rgb(p, q, t)
|
||||
if t < 0 then
|
||||
t = t + 1
|
||||
end
|
||||
if t > 1 then
|
||||
t = t - 1
|
||||
end
|
||||
if t < 1 / 6 then
|
||||
return p + (q - p) * 6 * t
|
||||
end
|
||||
if t < 1 / 2 then
|
||||
return q
|
||||
end
|
||||
if t < 2 / 3 then
|
||||
return p + (q - p) * (2 / 3 - t) * 6
|
||||
end
|
||||
return p
|
||||
end
|
||||
|
||||
local q
|
||||
if l < 0.5 then
|
||||
q = l * (1 + s)
|
||||
else
|
||||
q = l + s - l * s
|
||||
end
|
||||
local p = 2 * l - q
|
||||
|
||||
r = hue2rgb(p, q, h + 1 / 3)
|
||||
g = hue2rgb(p, q, h)
|
||||
b = hue2rgb(p, q, h - 1 / 3)
|
||||
end
|
||||
|
||||
return r * 255, g * 255, b * 255
|
||||
end
|
||||
|
||||
function M.hexToHSL(hex)
|
||||
local hsluv = require("solarized-osaka.hsluv")
|
||||
local rgb = M.hex_to_rgb(hex)
|
||||
local h, s, l = M.rgbToHsl(rgb[1], rgb[2], rgb[3])
|
||||
|
||||
return string.format("hsl(%d, %d, %d)", math.floor(h + 0.5), math.floor(s + 0.5), math.floor(l + 0.5))
|
||||
end
|
||||
|
||||
--[[
|
||||
* Converts an HSL color value to RGB in Hex representation.
|
||||
* @param Number h The hue
|
||||
* @param Number s The saturation
|
||||
* @param Number l The lightness
|
||||
* @return String The hex representation
|
||||
]]
|
||||
function M.hslToHex(h, s, l)
|
||||
local r, g, b = M.hslToRgb(h / 360, s / 100, l / 100)
|
||||
|
||||
return string.format("#%02x%02x%02x", r, g, b)
|
||||
end
|
||||
|
||||
function M.replaceHexWithHSL()
|
||||
-- Get the current line number
|
||||
local line_number = vim.api.nvim_win_get_cursor(0)[1]
|
||||
|
||||
-- Get the line content
|
||||
local line_content = vim.api.nvim_buf_get_lines(0, line_number - 1, line_number, false)[1]
|
||||
|
||||
-- Find hex code patterns and replace them
|
||||
for hex in line_content:gmatch("#[0-9a-fA-F]+") do
|
||||
local hsl = M.hexToHSL(hex)
|
||||
line_content = line_content:gsub(hex, hsl)
|
||||
end
|
||||
|
||||
-- Set the line content back
|
||||
vim.api.nvim_buf_set_lines(0, line_number - 1, line_number, false, { line_content })
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
function M.toggleInlayHints()
|
||||
vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled())
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
return {
|
||||
-- Create annotations with one keybind, and jump your cursor in the inserted annotation
|
||||
{
|
||||
"danymat/neogen",
|
||||
keys = {
|
||||
{
|
||||
"<leader>cc",
|
||||
function()
|
||||
require("neogen").generate({})
|
||||
end,
|
||||
desc = "Neogen Comment",
|
||||
},
|
||||
},
|
||||
opts = { snippet_engine = "luasnip" },
|
||||
},
|
||||
|
||||
-- Incremental rename
|
||||
{
|
||||
"smjonas/inc-rename.nvim",
|
||||
cmd = "IncRename",
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- Refactoring tool
|
||||
{
|
||||
"ThePrimeagen/refactoring.nvim",
|
||||
keys = {
|
||||
{
|
||||
"<leader>r",
|
||||
function()
|
||||
require("refactoring").select_refactor()
|
||||
end,
|
||||
mode = "v",
|
||||
noremap = true,
|
||||
silent = true,
|
||||
expr = false,
|
||||
},
|
||||
},
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- Go forward/backward with square brackets
|
||||
{
|
||||
"echasnovski/mini.bracketed",
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
local bracketed = require("mini.bracketed")
|
||||
bracketed.setup({
|
||||
file = { suffix = "" },
|
||||
window = { suffix = "" },
|
||||
quickfix = { suffix = "" },
|
||||
yank = { suffix = "" },
|
||||
treesitter = { suffix = "n" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Better increase/descrease
|
||||
{
|
||||
"monaqa/dial.nvim",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<C-a>", function() return require("dial.map").inc_normal() end, expr = true, desc = "Increment" },
|
||||
{ "<C-x>", function() return require("dial.map").dec_normal() end, expr = true, desc = "Decrement" },
|
||||
},
|
||||
config = function()
|
||||
local augend = require("dial.augend")
|
||||
require("dial.config").augends:register_group({
|
||||
default = {
|
||||
augend.integer.alias.decimal,
|
||||
augend.integer.alias.hex,
|
||||
augend.date.alias["%Y/%m/%d"],
|
||||
augend.constant.alias.bool,
|
||||
augend.semver.alias.semver,
|
||||
augend.constant.new({ elements = { "let", "const" } }),
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"simrat39/symbols-outline.nvim",
|
||||
keys = { { "<leader>cs", "<cmd>SymbolsOutline<cr>", desc = "Symbols Outline" } },
|
||||
cmd = "SymbolsOutline",
|
||||
opts = {
|
||||
position = "right",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-cmp",
|
||||
dependencies = { "hrsh7th/cmp-emoji" },
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, { name = "emoji" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
return {
|
||||
{
|
||||
"craftzdog/solarized-osaka.nvim",
|
||||
lazy = true,
|
||||
priority = 1000,
|
||||
opts = function()
|
||||
return {
|
||||
transparent = true,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,237 +0,0 @@
|
|||
return {
|
||||
{
|
||||
enabled = false,
|
||||
"folke/flash.nvim",
|
||||
---@type Flash.Config
|
||||
opts = {
|
||||
search = {
|
||||
forward = true,
|
||||
multi_window = false,
|
||||
wrap = false,
|
||||
incremental = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"echasnovski/mini.hipatterns",
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
highlighters = {
|
||||
hsl_color = {
|
||||
pattern = "hsl%(%d+,? %d+%%?,? %d+%%?%)",
|
||||
group = function(_, match)
|
||||
local utils = require("solarized-osaka.hsl")
|
||||
--- @type string, string, string
|
||||
local nh, ns, nl = match:match("hsl%((%d+),? (%d+)%%?,? (%d+)%%?%)")
|
||||
--- @type number?, number?, number?
|
||||
local h, s, l = tonumber(nh), tonumber(ns), tonumber(nl)
|
||||
--- @type string
|
||||
local hex_color = utils.hslToHex(h, s, l)
|
||||
return MiniHipatterns.compute_hex_color_group(hex_color, "bg")
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"dinhhuy258/git.nvim",
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
keymaps = {
|
||||
-- Open blame window
|
||||
blame = "<Leader>gb",
|
||||
-- Open file/folder in git repository
|
||||
browse = "<Leader>go",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
build = "make",
|
||||
},
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<leader>fP",
|
||||
function()
|
||||
require("telescope.builtin").find_files({
|
||||
cwd = require("lazy.core.config").options.root,
|
||||
})
|
||||
end,
|
||||
desc = "Find Plugin File",
|
||||
},
|
||||
{
|
||||
";f",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.find_files({
|
||||
no_ignore = false,
|
||||
hidden = true,
|
||||
})
|
||||
end,
|
||||
desc = "Lists files in your current working directory, respects .gitignore",
|
||||
},
|
||||
{
|
||||
";r",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.live_grep({
|
||||
additional_args = { "--hidden" },
|
||||
})
|
||||
end,
|
||||
desc = "Search for a string in your current working directory and get results live as you type, respects .gitignore",
|
||||
},
|
||||
{
|
||||
"\\\\",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.buffers()
|
||||
end,
|
||||
desc = "Lists open buffers",
|
||||
},
|
||||
{
|
||||
";t",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.help_tags()
|
||||
end,
|
||||
desc = "Lists available help tags and opens a new window with the relevant help info on <cr>",
|
||||
},
|
||||
{
|
||||
";;",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.resume()
|
||||
end,
|
||||
desc = "Resume the previous telescope picker",
|
||||
},
|
||||
{
|
||||
";e",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.diagnostics()
|
||||
end,
|
||||
desc = "Lists Diagnostics for all open buffers or a specific buffer",
|
||||
},
|
||||
{
|
||||
";s",
|
||||
function()
|
||||
local builtin = require("telescope.builtin")
|
||||
builtin.treesitter()
|
||||
end,
|
||||
desc = "Lists Function names, variables, from Treesitter",
|
||||
},
|
||||
{
|
||||
"sf",
|
||||
function()
|
||||
local telescope = require("telescope")
|
||||
|
||||
local function telescope_buffer_dir()
|
||||
return vim.fn.expand("%:p:h")
|
||||
end
|
||||
|
||||
telescope.extensions.file_browser.file_browser({
|
||||
path = "%:p:h",
|
||||
cwd = telescope_buffer_dir(),
|
||||
respect_gitignore = false,
|
||||
hidden = true,
|
||||
grouped = true,
|
||||
previewer = false,
|
||||
initial_mode = "normal",
|
||||
layout_config = { height = 40 },
|
||||
})
|
||||
end,
|
||||
desc = "Open File Browser with the path of the current buffer",
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
local fb_actions = require("telescope").extensions.file_browser.actions
|
||||
|
||||
opts.defaults = vim.tbl_deep_extend("force", opts.defaults, {
|
||||
wrap_results = true,
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = { prompt_position = "top" },
|
||||
sorting_strategy = "ascending",
|
||||
winblend = 0,
|
||||
mappings = {
|
||||
n = {},
|
||||
},
|
||||
})
|
||||
opts.pickers = {
|
||||
diagnostics = {
|
||||
theme = "ivy",
|
||||
initial_mode = "normal",
|
||||
layout_config = {
|
||||
preview_cutoff = 9999,
|
||||
},
|
||||
},
|
||||
}
|
||||
opts.extensions = {
|
||||
file_browser = {
|
||||
theme = "dropdown",
|
||||
-- disables netrw and use telescope-file-browser in its place
|
||||
hijack_netrw = true,
|
||||
mappings = {
|
||||
-- your custom insert mode mappings
|
||||
["n"] = {
|
||||
-- your custom normal mode mappings
|
||||
["N"] = fb_actions.create,
|
||||
["h"] = fb_actions.goto_parent_dir,
|
||||
["/"] = function()
|
||||
vim.cmd("startinsert")
|
||||
end,
|
||||
["<C-u>"] = function(prompt_bufnr)
|
||||
for i = 1, 10 do
|
||||
actions.move_selection_previous(prompt_bufnr)
|
||||
end
|
||||
end,
|
||||
["<C-d>"] = function(prompt_bufnr)
|
||||
for i = 1, 10 do
|
||||
actions.move_selection_next(prompt_bufnr)
|
||||
end
|
||||
end,
|
||||
["<PageUp>"] = actions.preview_scrolling_up,
|
||||
["<PageDown>"] = actions.preview_scrolling_down,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
telescope.setup(opts)
|
||||
require("telescope").load_extension("fzf")
|
||||
require("telescope").load_extension("file_browser")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
opts = {
|
||||
completion = {
|
||||
menu = {
|
||||
winblend = vim.o.pumblend,
|
||||
},
|
||||
},
|
||||
signature = {
|
||||
window = {
|
||||
winblend = vim.o.pumblend,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"3rd/image.nvim",
|
||||
build = false, -- so that it doesn't build the rock https://github.com/3rd/image.nvim/issues/91#issuecomment-2453430239
|
||||
opts = {
|
||||
processor = "magick_cli",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
return {
|
||||
-- tools
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
"stylua",
|
||||
"selene",
|
||||
"luacheck",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"tailwindcss-language-server",
|
||||
"typescript-language-server",
|
||||
"css-lsp",
|
||||
"clangd",
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- lsp servers
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
inlay_hints = { enabled = false },
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
cssls = {},
|
||||
tailwindcss = {
|
||||
root_dir = function(...)
|
||||
return require("lspconfig.util").root_pattern(".git")(...)
|
||||
end,
|
||||
},
|
||||
tsserver = {
|
||||
root_dir = function(...)
|
||||
return require("lspconfig.util").root_pattern(".git")(...)
|
||||
end,
|
||||
single_file_support = false,
|
||||
settings = {
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "literal",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = false,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
javascript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
html = {},
|
||||
yamlls = {
|
||||
settings = {
|
||||
yaml = {
|
||||
keyOrdering = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
lua_ls = {
|
||||
-- enabled = false,
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
workspaceWord = true,
|
||||
callSnippet = "Both",
|
||||
},
|
||||
misc = {
|
||||
parameters = {
|
||||
-- "--log-level=trace",
|
||||
},
|
||||
},
|
||||
hint = {
|
||||
enable = true,
|
||||
setType = false,
|
||||
paramType = true,
|
||||
paramName = "Disable",
|
||||
semicolon = "Disable",
|
||||
arrayIndex = "Disable",
|
||||
},
|
||||
doc = {
|
||||
privateName = { "^_" },
|
||||
},
|
||||
type = {
|
||||
castNumberToInteger = true,
|
||||
},
|
||||
diagnostics = {
|
||||
disable = { "incomplete-signature-doc", "trailing-space" },
|
||||
-- enable = false,
|
||||
groupSeverity = {
|
||||
strong = "Warning",
|
||||
strict = "Warning",
|
||||
},
|
||||
groupFileStatus = {
|
||||
["ambiguity"] = "Opened",
|
||||
["await"] = "Opened",
|
||||
["codestyle"] = "None",
|
||||
["duplicate"] = "Opened",
|
||||
["global"] = "Opened",
|
||||
["luadoc"] = "Opened",
|
||||
["redefined"] = "Opened",
|
||||
["strict"] = "Opened",
|
||||
["strong"] = "Opened",
|
||||
["type-check"] = "Opened",
|
||||
["unbalanced"] = "Opened",
|
||||
["unused"] = "Opened",
|
||||
},
|
||||
unusedLocalExclude = { "_*" },
|
||||
},
|
||||
format = {
|
||||
enable = false,
|
||||
defaultConfig = {
|
||||
indent_style = "space",
|
||||
indent_size = "2",
|
||||
continuation_indent_size = "2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
gopls = {
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
shadow = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
clangd = {
|
||||
cmd = { "clangd", "--background-index" },
|
||||
filetypes = { "c", "cpp", "objc", "objcpp" },
|
||||
root_dir = function(...)
|
||||
return require("lspconfig.util").root_pattern(
|
||||
"compile_commands.json",
|
||||
"compile_flags.txt",
|
||||
".git"
|
||||
)(...)
|
||||
end,
|
||||
},
|
||||
},
|
||||
setup = {},
|
||||
},
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function()
|
||||
local keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
vim.list_extend(keys, {
|
||||
{
|
||||
"gd",
|
||||
function()
|
||||
-- DO NOT RESUSE WINDOW
|
||||
require("telescope.builtin").lsp_definitions({ reuse_win = false })
|
||||
end,
|
||||
desc = "Goto Definition",
|
||||
has = "definition",
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
return {
|
||||
{ "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" },
|
||||
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"astro",
|
||||
"cmake",
|
||||
"cpp",
|
||||
"css",
|
||||
"fish",
|
||||
"gitignore",
|
||||
"go",
|
||||
"graphql",
|
||||
"http",
|
||||
"java",
|
||||
"php",
|
||||
"rust",
|
||||
"scss",
|
||||
"sql",
|
||||
"svelte",
|
||||
},
|
||||
|
||||
-- matchup = {
|
||||
-- enable = true,
|
||||
-- },
|
||||
|
||||
-- https://github.com/nvim-treesitter/playground#query-linter
|
||||
query_linter = {
|
||||
enable = true,
|
||||
use_virtual_text = true,
|
||||
lint_events = { "BufWrite", "CursorHold" },
|
||||
},
|
||||
|
||||
playground = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
|
||||
persist_queries = true, -- Whether the query persists across vim sessions
|
||||
keybindings = {
|
||||
toggle_query_editor = "o",
|
||||
toggle_hl_groups = "i",
|
||||
toggle_injected_languages = "t",
|
||||
toggle_anonymous_nodes = "a",
|
||||
toggle_language_display = "I",
|
||||
focus_language = "f",
|
||||
unfocus_language = "F",
|
||||
update = "R",
|
||||
goto_node = "<cr>",
|
||||
show_help = "?",
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
|
||||
-- MDX
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
mdx = "mdx",
|
||||
},
|
||||
})
|
||||
vim.treesitter.language.register("markdown", "mdx")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
return {
|
||||
-- messages, cmdline and the popupmenu
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.routes, {
|
||||
filter = {
|
||||
event = "notify",
|
||||
find = "No information available",
|
||||
},
|
||||
opts = { skip = true },
|
||||
})
|
||||
local focused = true
|
||||
vim.api.nvim_create_autocmd("FocusGained", {
|
||||
callback = function()
|
||||
focused = true
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("FocusLost", {
|
||||
callback = function()
|
||||
focused = false
|
||||
end,
|
||||
})
|
||||
table.insert(opts.routes, 1, {
|
||||
filter = {
|
||||
cond = function()
|
||||
return not focused
|
||||
end,
|
||||
},
|
||||
view = "notify_send",
|
||||
opts = { stop = false },
|
||||
})
|
||||
|
||||
opts.commands = {
|
||||
all = {
|
||||
-- options for the message history that you get with `:Noice`
|
||||
view = "split",
|
||||
opts = { enter = true, format = "details" },
|
||||
filter = {},
|
||||
},
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "markdown",
|
||||
callback = function(event)
|
||||
vim.schedule(function()
|
||||
require("noice.text.markdown").keys(event.buf)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
opts.presets.lsp_doc_border = true
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
opts = {
|
||||
timeout = 5000,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
scroll = { enabled = false },
|
||||
},
|
||||
keys = {},
|
||||
},
|
||||
|
||||
-- buffer line
|
||||
{
|
||||
"akinsho/bufferline.nvim",
|
||||
event = "VeryLazy",
|
||||
keys = {
|
||||
{ "<Tab>", "<Cmd>BufferLineCycleNext<CR>", desc = "Next tab" },
|
||||
{ "<S-Tab>", "<Cmd>BufferLineCyclePrev<CR>", desc = "Prev tab" },
|
||||
},
|
||||
opts = {
|
||||
options = {
|
||||
mode = "tabs",
|
||||
-- separator_style = "slant",
|
||||
show_buffer_close_icons = false,
|
||||
show_close_icon = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- filename
|
||||
{
|
||||
"b0o/incline.nvim",
|
||||
dependencies = { "craftzdog/solarized-osaka.nvim" },
|
||||
event = "BufReadPre",
|
||||
priority = 1200,
|
||||
config = function()
|
||||
local colors = require("solarized-osaka.colors").setup()
|
||||
require("incline").setup({
|
||||
highlight = {
|
||||
groups = {
|
||||
InclineNormal = { guibg = colors.magenta500, guifg = colors.base04 },
|
||||
InclineNormalNC = { guifg = colors.violet500, guibg = colors.base03 },
|
||||
},
|
||||
},
|
||||
window = { margin = { vertical = 0, horizontal = 1 } },
|
||||
hide = {
|
||||
cursorline = true,
|
||||
},
|
||||
render = function(props)
|
||||
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
|
||||
if vim.bo[props.buf].modified then
|
||||
filename = "[+] " .. filename
|
||||
end
|
||||
|
||||
local icon, color = require("nvim-web-devicons").get_icon_color(filename)
|
||||
return { { icon, guifg = color }, { " " }, { filename } }
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- statusline
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
opts = function(_, opts)
|
||||
local LazyVim = require("lazyvim.util")
|
||||
opts.sections.lualine_c[4] = {
|
||||
LazyVim.lualine.pretty_path({
|
||||
length = 0,
|
||||
relative = "cwd",
|
||||
modified_hl = "MatchParen",
|
||||
directory_hl = "",
|
||||
filename_hl = "Bold",
|
||||
modified_sign = "",
|
||||
readonly_icon = " ",
|
||||
}),
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"folke/zen-mode.nvim",
|
||||
cmd = "ZenMode",
|
||||
opts = {
|
||||
plugins = {
|
||||
gitsigns = true,
|
||||
tmux = true,
|
||||
kitty = { enabled = false, font = "+2" },
|
||||
},
|
||||
},
|
||||
keys = { { "<leader>z", "<cmd>ZenMode<cr>", desc = "Zen Mode" } },
|
||||
},
|
||||
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
dashboard = {
|
||||
preset = {
|
||||
header = [[
|
||||
██████╗ ███████╗██╗ ██╗ █████╗ ███████╗██╗ ██╗███████╗███████╗
|
||||
██╔══██╗██╔════╝██║ ██║██╔══██╗██╔════╝██║ ██║██╔════╝██╔════╝
|
||||
██║ ██║█████╗ ██║ ██║███████║███████╗██║ ██║█████╗ █████╗
|
||||
██║ ██║██╔══╝ ╚██╗ ██╔╝██╔══██║╚════██║██║ ██║██╔══╝ ██╔══╝
|
||||
██████╔╝███████╗ ╚████╔╝ ██║ ██║███████║███████╗██║██║ ███████╗
|
||||
╚═════╝ ╚══════╝ ╚═══╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚══════╝
|
||||
]],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
-- selene: allow(global_usage)
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.get_loc()
|
||||
local me = debug.getinfo(1, "S")
|
||||
local level = 2
|
||||
local info = debug.getinfo(level, "S")
|
||||
while info and (info.source == me.source or info.source == "@" .. vim.env.MYVIMRC or info.what ~= "Lua") do
|
||||
level = level + 1
|
||||
info = debug.getinfo(level, "S")
|
||||
end
|
||||
info = info or me
|
||||
local source = info.source:sub(2)
|
||||
source = vim.loop.fs_realpath(source) or source
|
||||
return source .. ":" .. info.linedefined
|
||||
end
|
||||
|
||||
---@param value any
|
||||
---@param opts? {loc:string}
|
||||
function M._dump(value, opts)
|
||||
opts = opts or {}
|
||||
opts.loc = opts.loc or M.get_loc()
|
||||
if vim.in_fast_event() then
|
||||
return vim.schedule(function()
|
||||
M._dump(value, opts)
|
||||
end)
|
||||
end
|
||||
opts.loc = vim.fn.fnamemodify(opts.loc, ":~:.")
|
||||
local msg = vim.inspect(value)
|
||||
vim.notify(msg, vim.log.levels.INFO, {
|
||||
title = "Debug: " .. opts.loc,
|
||||
on_open = function(win)
|
||||
vim.wo[win].conceallevel = 3
|
||||
vim.wo[win].concealcursor = ""
|
||||
vim.wo[win].spell = false
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
if not pcall(vim.treesitter.start, buf, "lua") then
|
||||
vim.bo[buf].filetype = "lua"
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function M.dump(...)
|
||||
local value = { ... }
|
||||
if vim.tbl_isempty(value) then
|
||||
value = nil
|
||||
else
|
||||
value = vim.tbl_islist(value) and vim.tbl_count(value) <= 1 and value[1] or value
|
||||
end
|
||||
M._dump(value)
|
||||
end
|
||||
|
||||
function M.extmark_leaks()
|
||||
local nsn = vim.api.nvim_get_namespaces()
|
||||
|
||||
local counts = {}
|
||||
|
||||
for name, ns in pairs(nsn) do
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
local count = #vim.api.nvim_buf_get_extmarks(buf, ns, 0, -1, {})
|
||||
if count > 0 then
|
||||
counts[#counts + 1] = {
|
||||
name = name,
|
||||
buf = buf,
|
||||
count = count,
|
||||
ft = vim.bo[buf].ft,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(counts, function(a, b)
|
||||
return a.count > b.count
|
||||
end)
|
||||
dd(counts)
|
||||
end
|
||||
|
||||
function estimateSize(value, visited)
|
||||
if value == nil then
|
||||
return 0
|
||||
end
|
||||
local bytes = 0
|
||||
|
||||
-- initialize the visited table if not already done
|
||||
--- @type table<any, true>
|
||||
visited = visited or {}
|
||||
|
||||
-- handle already-visited value to avoid infinite recursion
|
||||
if visited[value] then
|
||||
return 0
|
||||
else
|
||||
visited[value] = true
|
||||
end
|
||||
|
||||
if type(value) == "boolean" or value == nil then
|
||||
bytes = 4
|
||||
elseif type(value) == "number" then
|
||||
bytes = 8
|
||||
elseif type(value) == "string" then
|
||||
bytes = string.len(value) + 24
|
||||
elseif type(value) == "function" then
|
||||
bytes = 32 -- base size for a function
|
||||
-- add size of upvalues
|
||||
local i = 1
|
||||
while true do
|
||||
local name, val = debug.getupvalue(value, i)
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
bytes = bytes + estimateSize(val, visited)
|
||||
i = i + 1
|
||||
end
|
||||
elseif type(value) == "table" then
|
||||
bytes = 40 -- base size for a table entry
|
||||
for k, v in pairs(value) do
|
||||
bytes = bytes + estimateSize(k, visited) + estimateSize(v, visited)
|
||||
end
|
||||
local mt = debug.getmetatable(value)
|
||||
if mt then
|
||||
bytes = bytes + estimateSize(mt, visited)
|
||||
end
|
||||
end
|
||||
return bytes
|
||||
end
|
||||
|
||||
function M.module_leaks(filter)
|
||||
local sizes = {}
|
||||
for modname, mod in pairs(package.loaded) do
|
||||
if not filter or modname:match(filter) then
|
||||
local root = modname:match("^([^%.]+)%..*$") or modname
|
||||
-- root = modname
|
||||
sizes[root] = sizes[root] or { mod = root, size = 0 }
|
||||
sizes[root].size = sizes[root].size + estimateSize(mod) / 1024 / 1024
|
||||
end
|
||||
end
|
||||
sizes = vim.tbl_values(sizes)
|
||||
table.sort(sizes, function(a, b)
|
||||
return a.size > b.size
|
||||
end)
|
||||
dd(sizes)
|
||||
end
|
||||
|
||||
function M.get_upvalue(func, name)
|
||||
local i = 1
|
||||
while true do
|
||||
local n, v = debug.getupvalue(func, i)
|
||||
if not n then
|
||||
break
|
||||
end
|
||||
if n == name then
|
||||
return v
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Reference in a new issue