Last active
November 14, 2024 19:24
-
-
Save toruticas/f32c93b9168b79b555a028acd10f15be to your computer and use it in GitHub Desktop.
Neovim configs: ~/.config/nvim/*
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local iron = require("iron.core") | |
local view = require("iron.view") | |
iron.setup { | |
config = { | |
-- Whether a repl should be discarded or not | |
scratch_repl = true, | |
-- Your repl definitions come here | |
repl_definition = { | |
sh = { | |
-- Can be a table or a function that | |
-- returns a table (see below) | |
command = { "zsh" } | |
} | |
}, | |
-- How the repl window will be displayed | |
-- See below for more information | |
repl_open_cmd = require('iron.view').bottom(40), | |
}, | |
-- Iron doesn't set keymaps by default anymore. | |
-- You can set them here or manually add keymaps to the functions in iron.core | |
keymaps = { | |
send_motion = "<space>sc", | |
visual_send = "<space>sc", | |
send_file = "<space>sf", | |
send_line = "<space>sl", | |
send_mark = "<space>sm", | |
mark_motion = "<space>mc", | |
mark_visual = "<space>mc", | |
remove_mark = "<space>md", | |
cr = "<space>s<cr>", | |
interrupt = "<space>s<space>", | |
exit = "<space>sq", | |
clear = "<space>cl", | |
}, | |
-- If the highlight is on, you can change how it looks | |
-- For the available options, check nvim_set_hl | |
highlight = { | |
italic = true | |
}, | |
ignore_blank_lines = true, -- ignore blank lines when sending visual select lines | |
} | |
-- iron also has a list of commands, see :h iron-commands for all available commands | |
vim.keymap.set('n', '<space>rs', '<cmd>IronRepl<cr>') | |
vim.keymap.set('n', '<space>rr', '<cmd>IronRestart<cr>') | |
vim.keymap.set('n', '<space>rf', '<cmd>IronFocus<cr>') | |
vim.keymap.set('n', '<space>rh', '<cmd>IronHide<cr>') | |
require("todo-comments").setup { | |
-- your configuration comes here | |
-- or leave it empty to use the default settings | |
-- refer to the configuration section below | |
} | |
-- require('config') | |
-- vim.cmd('/Users/rs0230/.config/nvim/lua/setup.vim') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lua require('plugins') | |
lua require('init') | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => GENERAL | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
" Enable the line number on the left | |
set number | |
" set relativenumber | |
" Timer to execute commands periodically | |
set updatetime=250 | |
" Enable filetype plugin for detecting the type of file edited | |
filetype plugin on | |
filetype indent plugin on | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => COLORS AND FONTS | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlight | |
syntax on | |
set background=dark "dark or light | |
colorscheme gruvbox | |
" set background=light "dark or light | |
" colorscheme solarized | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => FILES | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Turn backup off, since most stuff is in SVN, git etc. anyway... | |
set nobackup | |
set nowritebackup | |
set noswapfile | |
" [FZF] Key map to open fuzzy finder | |
nmap <C-p> :FZF<CR> | |
nmap <C-o> :Files %:p:h/<CR> | |
nmap <C-i> :Buffers<CR> | |
nmap <C-f> :Rg! | |
" nmap <C-g> :GFiles<CR> | |
" [FZF] Define the fuzzy finder command | |
let $FZF_DEFAULT_COMMAND = "fd --hidden --type f" | |
let $FZF_CTRL_T_COMMAND = $FZF_DEFAULT_COMMAND | |
" Copies just the filename to the clipboard | |
nmap ,,cs :let @*=expand("%")<CR> | |
" Copies the filaname including its full path | |
nmap ,,cl :let @*=expand("%:p")<CR> | |
" Copies just the fila path to the clipboard | |
nmap ,,ch :let @*=expand("%:h")<CR> | |
" Split and go to definition | |
nnoremap <C-W><C-F> <C-W>vgf | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => USER INTERFACE AND NAVIGATION | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Display all invisible characters | |
set list | |
" Define the list of invisible characters | |
set listchars=eol:⏎,tab:>-,trail:·,extends:>,precedes:< | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Ignore case when searching | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Enable hightlight the cursor line | |
set cursorline | |
" Show matching brackets when text indicator is over theme | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
"Easier split navigation | |
nnoremap <C-J> <C-W><C-J> | |
nnoremap <C-K> <C-W><C-K> | |
nnoremap <C-L> <C-W><C-L> | |
nnoremap <C-H> <C-W><C-H> | |
"Move around in insert | |
inoremap <C-k> <C-o>gk | |
inoremap <C-h> <Left> | |
inoremap <C-l> <Right> | |
inoremap <C-j> <C-o>gj | |
" No annoying sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" Avoid garbled characters in Chinese language windows OS | |
let $LANG='en' | |
set langmenu=en | |
source $VIMRUNTIME/delmenu.vim | |
source $VIMRUNTIME/menu.vim | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => EDITOR | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Insert space characters whenever the tab key is pressed | |
set expandtab | |
" | |
" Number of spaces to use for each step of (auto)indent | |
set shiftwidth=2 | |
" | |
" Enable smart-tabs | |
set smarttab | |
" | |
" Number of spaces per Tab | |
set softtabstop=0 | |
" Control the number of space characters that will be inserted when the tab key is pressed | |
set tabstop=4 | |
"Auto indent | |
set autoindent | |
"Smart indent | |
set smartindent | |
" | |
"Wrap lines | |
set wrap | |
" Add a new line after the cursor on visual mode | |
nnoremap o o<Esc> | |
" Add a new line before the cursor on visual mode | |
nnoremap O O<Esc> | |
" Select all the file file with visual block | |
" nmap <leader>a ggVG | |
" Yank all the file | |
nmap <leader>ya gg"+yG`` | |
" Copy text from vim to clipboard | |
noremap <Leader>y "+y | |
" Paste text from clipboard to vim | |
noremap <Leader>p "+p | |
" [NERDCommenter] Add spaces after comment delimiters by default | |
let g:NERDSpaceDelims = 1 | |
" [NERDCommenter] Enable trimming of trailing whitespace when uncommenting | |
let g:NERDTrimTrailingWhitespace = 1 | |
" [NERDCommenter] Align line-wise comment delimiters flush left instead of following code indentation | |
let g:NERDDefaultAlign = 'left' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Spell checking | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 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= | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Vim Test | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nmap <silent> <leader>t :TestNearest<CR> | |
nmap <silent> <leader>T :TestFile<CR> | |
" The next line conflicts with CoC | |
nmap <silent> <leader>a :TestSuite<CR> | |
nmap <silent> <leader>l :TestLast<CR> | |
nmap <silent> <leader>g :TestVisit<CR> | |
let test#strategy = { | |
\ 'nearest': 'neovim', | |
\ 'file': 'dispatch', | |
\ 'suite': 'basic', | |
\} | |
let test#python#runner = 'pytest' | |
let test#python#pytest#options = '--no-header -q -W ignore::DeprecationWarning' | |
let g:test#javascript#runner = 'jest' | |
let g:test#javascript#jest#file_pattern = '\v.*\.(spec|test)\.(ts|tsx)$' | |
function! TypeScriptTransform(cmd) abort | |
return substitute(a:cmd, '\v(.*)mocha', 'TS_NODE_FILES=true \1ts-mocha', '') | |
endfunction | |
let g:test#custom_transformations = {'typescript': function('TypeScriptTransform')} | |
let g:test#transformation = 'typescript' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => MISCELLANEOUS | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" javascript source path | |
set path=.,src | |
" copy file to clipboard | |
nmap <leader>cs :let @*=expand("%")<CR> | |
nmap <leader>cl :let @*=expand("%:p")<CR> | |
" noremap <leader>s :update<CR> | |
" Enables goto file | |
set mouse=nicr | |
" To search for visually selected text use // | |
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR> | |
set omnifunc=syntaxcomplete#Complete | |
hi DiffAdd gui=NONE guifg=green guibg=black | |
" Disable Folding | |
let g:vim_markdown_folding_disabled = 1 | |
" set ttymouse=xterm2 | |
set mouse=a | |
let g:surround_116 = "(\"\r\")" | |
command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""" => CONFIC COC DEFAULTS | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" TextEdit might fail if hidden is not set. | |
set hidden | |
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable | |
" delays and poor user experience. | |
set updatetime=300 | |
" Always show the signcolumn, otherwise it would shift the text each time | |
" diagnostics appear/become resolved. | |
set signcolumn=yes | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: There's always complete item selected by default, you may want to enable | |
" no select by `"suggest.noselect": true` in your configuration file. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
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 or notify coc.nvim to format | |
" <C-g>u breaks current undo, please make your own choice. | |
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. | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" Use `[g` and `]g` to navigate diagnostics | |
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. | |
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) | |
augroup mygroup | |
autocmd! | |
" Setup formatexpr specified filetype(s). | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
" Update signature help on jump placeholder. | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
" Applying codeAction to the selected region. | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current buffer. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Run the Code Lens action on the current line. | |
nmap <leader>cl <Plug>(coc-codelens-action) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
" Remap <C-f> and <C-b> for scroll float windows/popups. | |
if has('nvim-0.4.0') || has('patch-8.2.0750') | |
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
endif | |
" Use CTRL-S for selections ranges. | |
" Requires 'textDocument/selectionRange' support of language server. | |
nmap <silent> <C-s> <Plug>(coc-range-select) | |
xmap <silent> <C-s> <Plug>(coc-range-select) | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocActionAsync('format') | |
" Add `:Fold` command to fold current buffer. | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') | |
" Add (Neo)Vim's native statusline support. | |
" NOTE: Please see `:h coc-status` for integrations with external plugins that | |
" provide custom statusline: lightline.vim, vim-airline. | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
" Mappings for CoCList | |
" Show all diagnostics. | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions. | |
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> | |
" Show commands. | |
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document. | |
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols. | |
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list. | |
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> | |
" Vsplit and call coc-definition | |
nmap <silent> gv :vsp<CR><Plug>(coc-definition) | |
" Close all floating ballon (useful when errors occur) | |
noremap <Leader>r :lua for _, win in ipairs(vim.api.nvim_list_wins()) do local config = vim.api.nvim_win_get_config(win); if config.relative ~= "" then vim.api.nvim_win_close(win, false); print('Closing window', win) end end<cr> | |
function! s:Camelize(range, character) abort | |
if a:character == '-' | |
if a:range == 0 | |
s#\(\%(\<\l\+\)\%(-\)\@=\)\|-\(\l\)#\u\1\2#g | |
else | |
s#\%V\(\%(\<\l\+\)\%(-\)\@=\)\|-\(\l\)\%V#\u\1\2#g | |
endif | |
else | |
if a:range == 0 | |
s#\(\%(\<\l\+\)\%(_\)\@=\)\|_\(\l\)#\u\1\2#g | |
else | |
s#\%V\(\%(\<\l\+\)\%(_\)\@=\)\|_\(\l\)\%V#\u\1\2#g | |
endif | |
endif | |
endfunction | |
function! s:Snakeize(range) abort | |
if a:range == 0 | |
s#\C\(\<\u[a-z0-9]\+\|[a-z0-9]\+\)\(\u\)#\l\1_\l\2#g | |
else | |
s#\%V\C\(\<\u[a-z0-9]\+\|[a-z0-9]\+\)\(\u\)\%V#\l\1_\l\2#g | |
endif | |
endfunction | |
command! -range CamelCase silent! call <SID>Camelize(<range>, '_') | |
command! -range CamelCase2 silent! call <SID>Camelize(<range>, '-') | |
command! -range SnakeCase silent! call <SID>Snakeize(<range>) | |
function! Wipeout() | |
" list of *all* buffer numbers | |
let l:buffers = range(1, bufnr('$')) | |
" what tab page are we in? | |
let l:currentTab = tabpagenr() | |
try | |
" go through all tab pages | |
let l:tab = 0 | |
while l:tab < tabpagenr('$') | |
let l:tab += 1 | |
" go through all windows | |
let l:win = 0 | |
while l:win < winnr('$') | |
let l:win += 1 | |
" whatever buffer is in this window in this tab, remove it from | |
" l:buffers list | |
let l:thisbuf = winbufnr(l:win) | |
call remove(l:buffers, index(l:buffers, l:thisbuf)) | |
endwhile | |
endwhile | |
" if there are any buffers left, delete them | |
if len(l:buffers) | |
execute 'bwipeout' join(l:buffers) | |
endif | |
finally | |
" go back to our original tab page | |
execute 'tabnext' l:currentTab | |
endtry | |
endfunction | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Plug = vim.fn['plug#'] | |
vim.call('plug#begin', '~/.config/nvim/plugged') | |
-- Vim motions on speed | |
Plug('easymotion/vim-easymotion') | |
-- Use RipGrep in Vim and display results in a quickfix list | |
Plug('jremmen/vim-ripgrep') | |
-- Things you can do with fzf and Vim. | |
Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' }) | |
Plug('junegunn/fzf.vim') | |
-- " Intensely nerdy commenting powers | |
Plug('scrooloose/nerdcommenter') | |
-- " Clean, vibrant and pleasing color schemes for Vim, Sublime Text, iTerm, gnome-terminal and more. | |
-- " Plug 'sonph/onehalf', {'rtp': 'vim/'} | |
Plug('morhetz/gruvbox') | |
Plug('altercation/vim-colors-solarized') | |
-- " A Git wrapper so awesome, it should be illegal | |
Plug('tpope/vim-fugitive') | |
Plug('idanarye/vim-merginal') | |
-- " Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more | |
Plug('tpope/vim-surround') | |
-- " Lean & mean status/tabline for vim that's light as air | |
Plug('vim-airline/vim-airline') | |
Plug('vim-airline/vim-airline-themes') | |
-- " Use release branch (recommend) | |
Plug('neoclide/coc.nvim', { ['branch'] = 'release' }) | |
-- " Friendly start screen | |
Plug('mhinz/vim-startify') | |
Plug('edluffy/hologram.nvim') | |
-- " A Vim wrapper for running tests on different granularities. | |
Plug('vim-test/vim-test') | |
-- " Interactive Repls Over Neovim | |
Plug('hkupty/iron.nvim') | |
-- " Syntaxes highlight | |
Plug('sheerun/vim-polyglot') | |
-- """"""""""""""""""""" | |
-- " AUTO FORMATTER & AUTOCOMPLETER | |
-- """"""""""""""""""""" | |
Plug('editorconfig/editorconfig-vim') | |
Plug('godlygeek/tabular') | |
Plug('nvim-lua/plenary.nvim') | |
Plug('folke/todo-comments.nvim') | |
vim.call('plug#end') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment