diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..1939ba4 --- /dev/null +++ b/.vimrc @@ -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 w :w! + +" Fast quitting +nmap q :q + +" Fast save and quit +nmap x :x + +" Disable highlight when is pressed +map :noh + +" Smart way to move between windows +map j +map k +map h +map l + +" Close the current buffer +map bd :Bclose:tabclosegT + +" Close all the buffers +map ba :bufdo bd + +" Next buffer +map l :bnext + +" Previous buffer +map h :bprevious + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nmap tl :exe "tabn ".g:lasttab +au TabLeave * let g:lasttab = tabpagenr() + +" Opens a new tab with the current buffer's path +map te :tabedit =expand("%:p:h")/ + +" Switch CWD to the directory of the open buffer +map cd :cd %:p:h:pwd + +" Remap VIM 0 to first non-blank character +map 0 ^ + +" Move a line of text using ALT+[jk] or Command+[jk] on mac +nmap mz:m+`z +nmap mz:m-2`z +vmap :m'>+`mzgv`yo`z +vmap :m'<-2`>my`ss :setlocal spell! + +" Shortcuts using +map sn ]s +map sp [s +map sa zg +map s? z= + +" Remove trailing whitespace +nnoremap w :let _s=@/:%s/\s\+$//e:let @/=_s + +" Toggle paste mode +set pastetoggle= + +" Toggle line numbers +nnoremap :set invnumber + +" Toggle relative line numbers +nnoremap :set invrelativenumber + +" Enable folding with the spacebar +nnoremap za + +" ============================================================================ +" => Plugin Settings +" ============================================================================ + +" --- NERDTree --- +map :NERDTreeToggle +map n :NERDTreeFind + +" 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 :Files +map b :Buffers +map rg :Rg +map t :Tags + +" --- 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 aj :ALENext +nmap ak :ALEPrevious + +" --- Tagbar --- +nmap :TagbarToggle + +" --- UndoTree --- +nnoremap :UndotreeToggle + +" --- EasyMotion --- +let g:EasyMotion_do_mapping = 0 " Disable default mappings + +" Jump to anywhere you want with minimal keystrokes +nmap s (easymotion-overwin-f2) + +" Turn on case-insensitive feature +let g:EasyMotion_smartcase = 1 + +" JK motions: Line motions +map j (easymotion-j) +map k (easymotion-k) + +" --- CoC (Conquer of Completion) --- +if exists('g:plugs["coc.nvim"]') + " Use tab for trigger completion with characters ahead and navigate + inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() + inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + + " Make to accept selected completion item + inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + + function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + " Use to trigger completion + inoremap coc#refresh() + + " Use `[g` and `]g` to navigate diagnostics + nmap [g (coc-diagnostic-prev) + nmap ]g (coc-diagnostic-next) + + " GoTo code navigation + nmap gd (coc-definition) + nmap gy (coc-type-definition) + nmap gi (coc-implementation) + nmap gr (coc-references) + + " Use K to show documentation in preview window + nnoremap K :call ShowDocumentation() + + 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 rn (coc-rename) + + " Formatting selected code + xmap f (coc-format-selected) + nmap f (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 BufcloseCloseIt() +function! 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 q :e ~/buffer + +" Quickly open a markdown buffer for scribble +map m :e ~/buffer.md + +" Toggle between number and relativenumber +function! ToggleNumber() + if(&relativenumber == 1) + set norelativenumber + set number + else + set relativenumber + endif +endfunc + +" Toggle paste mode +map pp :setlocal paste! + +" ============================================================================ +" => 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 +" ============================================================================ diff --git a/README.md b/README.md index e8a2104..a7c79f0 100644 --- a/README.md +++ b/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. diff --git a/init.lua b/init.lua deleted file mode 100644 index 00d56f4..0000000 --- a/init.lua +++ /dev/null @@ -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") diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua deleted file mode 100644 index a9d3f98..0000000 --- a/lua/config/autocmds.lua +++ /dev/null @@ -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, -}) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua deleted file mode 100644 index 4a8a5bb..0000000 --- a/lua/config/keymaps.lua +++ /dev/null @@ -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", "p", '"0p') -keymap.set("n", "P", '"0P') -keymap.set("v", "p", '"0p') -keymap.set("n", "c", '"_c') -keymap.set("n", "C", '"_C') -keymap.set("v", "c", '"_c') -keymap.set("v", "C", '"_C') -keymap.set("n", "d", '"_d') -keymap.set("n", "D", '"_D') -keymap.set("v", "d", '"_d') -keymap.set("v", "D", '"_D') - --- Increment/decrement -keymap.set("n", "+", "") -keymap.set("n", "-", "") - --- Delete a word backwards -keymap.set("n", "dw", 'vb"_d') - --- Select all -keymap.set("n", "", "ggG") - --- 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", "o", "o^Da", opts) -keymap.set("n", "O", "O^Da", opts) - --- Jumplist -keymap.set("n", "", "", opts) - --- New tab -keymap.set("n", "te", ":tabedit") -keymap.set("n", "", ":tabnext", opts) -keymap.set("n", "", ":tabprev", opts) --- Split window -keymap.set("n", "ss", ":split", opts) -keymap.set("n", "sv", ":vsplit", opts) --- Move window -keymap.set("n", "sh", "h") -keymap.set("n", "sk", "k") -keymap.set("n", "sj", "j") -keymap.set("n", "sl", "l") - --- Resize window -keymap.set("n", "", "<") -keymap.set("n", "", ">") -keymap.set("n", "", "+") -keymap.set("n", "", "-") - --- Diagnostics -keymap.set("n", "", function() - vim.diagnostic.goto_next() -end, opts) - -keymap.set("n", "r", function() - require("m1ngsama.hsl").replaceHexWithHSL() -end) - -keymap.set("n", "i", function() - require("m1ngsama.lsp").toggleInlayHints() -end) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua deleted file mode 100644 index 014aa3b..0000000 --- a/lua/config/lazy.lua +++ /dev/null @@ -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 = { - ["d"] = function(plugin) - dd(plugin) - end, - }, - }, - debug = false, -}) diff --git a/lua/config/options.lua b/lua/config/options.lua deleted file mode 100644 index 218f64d..0000000 --- a/lua/config/options.lua +++ /dev/null @@ -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 diff --git a/lua/m1ngsama/discipline.lua b/lua/m1ngsama/discipline.lua deleted file mode 100644 index ff2c0d5..0000000 --- a/lua/m1ngsama/discipline.lua +++ /dev/null @@ -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 diff --git a/lua/m1ngsama/hsl.lua b/lua/m1ngsama/hsl.lua deleted file mode 100644 index 4c97404..0000000 --- a/lua/m1ngsama/hsl.lua +++ /dev/null @@ -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 diff --git a/lua/m1ngsama/lsp.lua b/lua/m1ngsama/lsp.lua deleted file mode 100644 index a52e945..0000000 --- a/lua/m1ngsama/lsp.lua +++ /dev/null @@ -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 diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua deleted file mode 100644 index 963e401..0000000 --- a/lua/plugins/coding.lua +++ /dev/null @@ -1,97 +0,0 @@ -return { - -- Create annotations with one keybind, and jump your cursor in the inserted annotation - { - "danymat/neogen", - keys = { - { - "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 = { - { - "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 = { - { "", function() return require("dial.map").inc_normal() end, expr = true, desc = "Increment" }, - { "", 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 = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, - cmd = "SymbolsOutline", - opts = { - position = "right", - }, - }, - - { - "nvim-cmp", - dependencies = { "hrsh7th/cmp-emoji" }, - opts = function(_, opts) - table.insert(opts.sources, { name = "emoji" }) - end, - }, -} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua deleted file mode 100644 index b126b70..0000000 --- a/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - { - "craftzdog/solarized-osaka.nvim", - lazy = true, - priority = 1000, - opts = function() - return { - transparent = true, - } - end, - }, -} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua deleted file mode 100644 index 507f52d..0000000 --- a/lua/plugins/editor.lua +++ /dev/null @@ -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 = "gb", - -- Open file/folder in git repository - browse = "go", - }, - }, - }, - - { - "nvim-telescope/telescope.nvim", - dependencies = { - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - }, - "nvim-telescope/telescope-file-browser.nvim", - }, - keys = { - { - "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 ", - }, - { - ";;", - 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, - [""] = function(prompt_bufnr) - for i = 1, 10 do - actions.move_selection_previous(prompt_bufnr) - end - end, - [""] = function(prompt_bufnr) - for i = 1, 10 do - actions.move_selection_next(prompt_bufnr) - end - end, - [""] = actions.preview_scrolling_up, - [""] = 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", - }, - }, -} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua deleted file mode 100644 index 3f03ea8..0000000 --- a/lua/plugins/lsp.lua +++ /dev/null @@ -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, - }, -} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua deleted file mode 100644 index f3443d2..0000000 --- a/lua/plugins/treesitter.lua +++ /dev/null @@ -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 = "", - 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, - }, -} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua deleted file mode 100644 index 692fd8f..0000000 --- a/lua/plugins/ui.lua +++ /dev/null @@ -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 = { - { "", "BufferLineCycleNext", desc = "Next tab" }, - { "", "BufferLineCyclePrev", 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 = { { "z", "ZenMode", desc = "Zen Mode" } }, - }, - - { - "folke/snacks.nvim", - opts = { - dashboard = { - preset = { - header = [[ - ██████╗ ███████╗██╗ ██╗ █████╗ ███████╗██╗ ██╗███████╗███████╗ - ██╔══██╗██╔════╝██║ ██║██╔══██╗██╔════╝██║ ██║██╔════╝██╔════╝ - ██║ ██║█████╗ ██║ ██║███████║███████╗██║ ██║█████╗ █████╗ - ██║ ██║██╔══╝ ╚██╗ ██╔╝██╔══██║╚════██║██║ ██║██╔══╝ ██╔══╝ - ██████╔╝███████╗ ╚████╔╝ ██║ ██║███████║███████╗██║██║ ███████╗ - ╚═════╝ ╚══════╝ ╚═══╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚══════╝ - ]], - }, - }, - }, - }, -} diff --git a/lua/util/debug.lua b/lua/util/debug.lua deleted file mode 100644 index 136823f..0000000 --- a/lua/util/debug.lua +++ /dev/null @@ -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 - 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