feat: add nvim

This commit is contained in:
2022-01-16 15:05:09 +08:00
parent f66e4a5f6b
commit 364134990d
78 changed files with 4144 additions and 821 deletions
+73
View File
@@ -0,0 +1,73 @@
command! LspCodeAction lua require 'lv-utils'.code_action()
command! LspDeclaration lua require 'lv-utils'.declaration()
command! LspDefinition lua require 'lv-utils'.definition()
command! LspDocumentSymbol lua require 'lv-utils'.document_symbol()
command! LspFormatting lua require 'lv-utils'.formatting()
command! LspFormattingSync lua require 'lv-utils'.formatting_sync()
command! LspHover lua require 'lv-utils'.hover()
command! LspImplementation lua require 'lv-utils'.implementation()
command! LspRangeCodeAction lua require 'lv-utils'.range_code_action()
command! LspRangeFormatting lua require 'lv-utils'.range_formatting()
command! LspReferences lua require 'lv-utils'.references()
command! LspRename lua require 'lv-utils'.rename()
command! LspTypeDefinition lua require 'lv-utils'.type_definition()
command! LspWorkspaceSymbol lua require 'lv-utils'.workspace_symbol()
command! LspGotoNext lua require 'lv-utils'.goto_next()
command! LspGotoPrev lua require 'lv-utils'.goto_prev()
command! LspShowLineDiagnostics lua require 'lv-utils'.show_line_diagnostics()
command! NextHunk lua require 'lv-utils'.next_hunk()
command! PrevHunk lua require 'lv-utils'.prev_hunk()
command! StageHunk lua require 'lv-utils'.stage_hunk()
command! UndoStageHunk lua require 'lv-utils'.undo_stage_hunk()
command! ResetHunk lua require 'lv-utils'.reset_hunk()
command! ResetBuffer lua require 'lv-utils'.reset_buffer()
command! PreviewHunk lua require 'lv-utils'.preview_hunk()
command! BlameLine lua require 'lv-utils'.blame_line()
command! W noa w
" Debugging
command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint()
command! DebugStart lua require'dap'.continue()
command! DebugContinue lua require'dap'.continue()
command! DebugStepOver lua require'dap'.step_over()
command! DebugStepOut lua require'dap'.step_out()
command! DebugStepInto lua require'dap'.step_into()
command! DebugToggleRepl lua require'dap'.repl.toggle()
command! DebugGetSession lua require'dap'.session()
" Available Debug Adapters:
" https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/
"
" Adapter configuration and installation instructions:
" https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
"
" Debug Adapter protocol:
" https://microsoft.github.io/debug-adapter-protocol/
" TODO Add full support later
" nnoremap <silent> <F5> :lua require'dap'.continue()<CR>
" nnoremap <silent> <F10> :lua require'dap'.step_over()<CR>
" nnoremap <silent> <F11> :lua require'dap'.step_into()<CR>
" nnoremap <silent> <F12> :lua require'dap'.step_out()<CR>
" nnoremap <silent> <leader>b :lua require'dap'.toggle_breakpoint()<CR>
" nnoremap <silent> <leader>B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
" nnoremap <silent> <leader>lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
" nnoremap <silent> <leader>dr :lua require'dap'.repl.open()<CR>
" nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>
autocmd! User GoyoEnter lua require('gitsigns').toggle_signs()
autocmd! User GoyoLeave lua require('gitsigns').toggle_signs()
autocmd User GoyoEnter set laststatus=0
autocmd User GoyoLeave set laststatus=2
" autocmd! User GoyoEnter lua require('galaxyline').disable_galaxyline()
" autocmd! User GoyoLeave lua require('galaxyline').galaxyline_augroup()
function! QuickFixToggle()
if empty(filter(getwininfo(), 'v:val.quickfix'))
copen
else
cclose
endif
endfunction
+84
View File
@@ -0,0 +1,84 @@
" packadd quickscope
execute 'luafile ' . stdpath('config') . '/lua/settings.lua'
function! s:manageEditorSize(...)
let count = a:1
let to = a:2
for i in range(1, count ? count : 1)
call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
endfor
endfunction
function! s:vscodeCommentary(...) abort
if !a:0
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
return 'g@'
elseif a:0 > 1
let [line1, line2] = [a:1, a:2]
else
let [line1, line2] = [line("'["), line("']")]
endif
call VSCodeCallRange("editor.action.commentLine", line1, line2, 0)
endfunction
function! s:openVSCodeCommandsInVisualMode()
normal! gv
let visualmode = visualmode()
if visualmode == "V"
let startLine = line("v")
let endLine = line(".")
call VSCodeNotifyRange("workbench.action.showCommands", startLine, endLine, 1)
else
let startPos = getpos("v")
let endPos = getpos(".")
call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1)
endif
endfunction
function! s:openWhichKeyInVisualMode()
normal! gv
let visualmode = visualmode()
if visualmode == "V"
let startLine = line("v")
let endLine = line(".")
call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1)
else
let startPos = getpos("v")
let endPos = getpos(".")
call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1)
endif
endfunction
" Better Navigation
nnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
xnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
nnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
xnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
nnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
xnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
nnoremap gr <Cmd>call VSCodeNotify('editor.action.goToReferences')<CR>
" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors
" xnoremap <expr> <C-/> <SID>vscodeCommentary()
" nnoremap <expr> <C-/> <SID>vscodeCommentary() . '_'
nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
nnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>
xnoremap <silent> <Space> :<C-u>call <SID>openWhichKeyInVisualMode()<CR>
xnoremap <silent> <C-P> :<C-u>call <SID>openVSCodeCommandsInVisualMode()<CR>
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
" Simulate same TAB behavior in VSCode
nmap <Tab> :Tabnext<CR>
nmap <S-Tab> :Tabprev<CR>