Browse Source

Merge branch 'master' of git.nucleardog.ca:nucleardog/nukevim

master
Adam Pippin 2 years ago
parent
commit
d0f7a0f60d
  1. 194
      doc/nukevim.txt
  2. 18
      init.lua
  3. 3
      lua/config/plugins/development.lua
  4. 112
      startup.vim

194
doc/nukevim.txt

@ -194,58 +194,252 @@ See: https://php.org/
3. Features *NukeVimFeature*
This section outlines several features included in the NukeVim distribution,
references back to the relevant projects, and quick information on their use.
--------------------------------------------------------------------------------
3.1 Development *NukeVimFeatureDev*
Tools for working with code.
--------------------------------------------------------------------------------
3.1.1 Debugger *NukeVimFeatureDebugger*
NukeVim includes the Vdebug plugin to provide a DBGP protocol debugger within
vim. It can be used for PHP (xdebug), Python, Ruby, Perl, Tcl, NodeJS and more.
Further Help: `:h Vdebug`
URL: https://github.com/vim-vdebug/vdebug
In normal mode:
* `<F5>` starts the debugger; the UI will only appear once a client connects
* `<F10>` toggle breakpoint
Within the debugger:
* `<F2>` step over
* `<F3>` step into
* `<F4>` step out
* `<F6>` stops the debugged code; a second time closes the debugger
* `<F9>` run to cursor
* `<F12>` evaluate variable under cursor
NukeVim provides some additionally functionality and mappings for working with
the debugger under the `<leader> d(evelopment) d(ebug)` prefix:
* `b` toggle breakpoint
* `c` set a conditional breakpoint
* `e` evaluate code; if you have a visual selection it will evaluate that,
otherwise it will prompt for code
* `t` set a trace expression to be evaluated on each stepping; if you have a
visual selection it will trace that, otherwise it will prompt for code
* `w` show breakpoint window listing all breakpoints
--------------------------------------------------------------------------------
3.1.2 Code Completion *NukeVimFeatureCodeCompletion*
NukeVim provides the coc plugin to provide completion.
Further Help: `:h coc-nvim`
URL: https://github.com/neoclide/coc.nvim
You can install various coc extensions with the `:CocInstall` command. Some
useful ones:
* `coc-css`: css completion
* `coc-html`: html completion
* `coc-json`: json completion
* `coc-markdownlint`: markdown linting rules
* `coc-marketplace`: run `:CocList marketplace` to fuzzy find and interactively
install new extensions
* `coc-phpls`: php language server using intelephense
* `coc-sql`: sql completion
* `coc-yaml`: yaml completion
When completion windows pop up, you can either:
* Scroll with the arrow keys, commit with <CR>
* Scroll with Ctrl+J/K and have the changes reflected immediately.
--------------------------------------------------------------------------------
3.1.3 Tag Bar *NukeVimFeatureTagBar*
NukeVim uses the tagbar plugin to provide overview and navigation of your
code's structure.
Further Help: `:h tagbar`
URL: https://github.com/preservim/tagbar
At any point in a source file, you can press `Alt+;` to open a sidebar which
shows all of the "tags" in your source file--classes and functions. You can
scroll with j/k and select any tag with <CR> to move the cursor there. The
window automatically closes.
--------------------------------------------------------------------------------
3.1.4 Todos *NukeVimFeatureTodos*
NukeVim uses trouble and todo-comments to provide highlighting and a project-level
overview of // TODO, // FIXME, etc style comments.
Further Help: none
URL: https://github.com/folke/todo-comments.nvim
todo-comments will search your cwd for relevant tags. Generally this will be
your project's directory thanks to vim-rooter.
You can trigger the quickfix interface with `<leader> w(orkspace) t(odos)`.
This will open the quickfix window with a list of todos broken down by file.
Scroll with j/k, select with <CR> to jump to the file and line, or close the
quickfix window with `q`. It will auto-close when you select a todo to view.
Alternatively, you can use `<leader> w(orkspace) T(odos)` to open the todos
in Telescope. This provides a fuzzy find interface with shows a preview of the
selected todo in the right pane.
--------------------------------------------------------------------------------
3.1.5 Git *NukeVimFeatureGit*
NukeVim uses several plugins to provide a whole bunch of relevant
git functionality.
All of the functionality can be found under the `<leader> g(it)` prefix.
--------------------------------------------------------------------------------
3.1.6 Docker *NukevimFeatureDocker*
NukeVim provides two docker interfaces out of the box, though one is disabled
by default.
| The default plugin requires deno be available (see |NukeVimDependencies|).
| If you do not want to install deno, you may instead enable
| the `vim-docker-tools plugin in `lua/config/plugins/development.lua`. This
| section only discusses the default denops-docker plugin.
Further Help: `:h docker.txt`
URL: https://github.com/skanehira/denops-docker.vim
denops-docker provides basic container and image management from within vim.
You can trigger container management with `<leader> d(evelopment) c(ontainers)`
and image management with `<leader> d(evelopment) i(mages)`.
All key bindings available in both interfaces are registered in the keymap so
live help can be found by pressing `???` with either window open. Windows can
be scrolled with j/k and closed with `q`.
Containers:
* `u` start container
* `d` stop container
* `r` restart container
* `<C-k>` kill container
* `<CR>` inspect container
* `a` attach terminal to container
* `t` tail log of container
* `<C-d>` delete container
Images:
* `r` run image
* `<C-d>` delete image
* `<CR>` inspect image
--------------------------------------------------------------------------------
3.2 PHP *NukeVimFeaturePhp*
NukeVim provides some PHP-specific functionality.
--------------------------------------------------------------------------------
3.2.1 Debugger *NukeVimFeaturePhpDebugger*
In order to debug PHP with Vdebug (see |NukeVimFeatureDebugger|), you must first
set up PHP correctly.
Ensure you have the xdebug extension (https://xdebug.org/) installed first. It's
likely available in your package manager.
I won't fully replicate the Xdebug documentation here, but you _will_ need to
properly configure xdebug in your php.ini file. Some core options you'll
likely need would be:
[xdebug]
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
xdebug.discover_client_host=true
xdebug.start_with_request=true
--------------------------------------------------------------------------------
3.2.2 Composer *NukeVimFeaturePhpComposer*
NukeVim provides an extremely basic composer interface thanks to vim-composer.
Further Help: `:h composer.txt`
URL: https://github.com/vim-php/vim-composer
The functionality is only available when you have a PHP file open and it is
all under the `<leader> l(anguage) c(omposer)` prefix:
* `i` run composer install
* `j` open composer.json in a new buffer
* `u` run composer update
// TODO: Add some more composer commands using :ComposerRun -- something generic
// but also probably some shortcuts for my common stuff like format/validate.
--------------------------------------------------------------------------------
3.3 UI *NukeVimFeatureUi*
Most of the UI stuff just... is, but there are a couple of things that aren't
very discoverable.
--------------------------------------------------------------------------------
3.3.1 Fuzzy Find *NukeVimFeatureUiFuzzyFind*
NukeVim uses CtrlP for fuzzy finding files.
Further Help: `:h ctrlp`
URL: https://github.com/ctrlpvim/ctrlp.vim
You can trigger the fuzzy find by pressing `<C-p>` in normal mode. This will
try and fuzzily match any files in the cwd (which should follow your project
root thanks to vim-rooter).
--------------------------------------------------------------------------------
3.3.2 Terminal *NukeVimFeatureUiTerminal*
NukeVim uses toggleterm to provide a persistent, toggleable terminal.
Further Help: `:h toggleterm`
URL: https://github.com/akinsho/toggleterm.nvim
In normal mode, press `<C-t>` to show/hide a terminal at the bottom of your
screen.
================================================================================
4. Architecture *NukeVimArch*

18
init.lua

@ -0,0 +1,18 @@
nukevim = require('nukevim'):new()
nukevim:enableCaching()
nukevim:initialize()
nukevim:run()
vim.api.nvim_create_autocmd("VimResized", {
command = "lua nukevim:gui()"
})
-- Should be able to do this with vim.api.nvim_add_user_command but
-- that doesn't seem to exist for some reason
vim.cmd[[ command! NukeVimInstall :lua nukevim:install() ]]
-- Include a vimscript file so you can use all of this without having to migrate
-- literally everything day 1.
vim.cmd('source ' .. vim.env.MYVIMRC:sub(1, -9) .. 'startup.vim')

3
lua/config/plugins/development.lua

@ -113,7 +113,8 @@ return {
name = 'folke/todo-comments.nvim',
config = { branch = "main" },
keys = {
{ mode = 'n', key = { '<leader>', 'w', 't' }, map = ':TodoTrouble<CR>', label = "todos" },
{ mode = 'n', key = { '<leader>', 'w', 't' }, map = ':TodoTrouble<CR>', label = "todos list" },
{ mode = 'n', key = { '<leader>', 'w', 'T' }, map = ':TodoTelescope<CR>', label = "todos search" },
}
},

112
startup.vim

@ -0,0 +1,112 @@
function! SynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
function! SynStack ()
for i1 in synstack(line("."), col("."))
let i2 = synIDtrans(i1)
let n1 = synIDattr(i1, "name")
let n2 = synIDattr(i2, "name")
echo n1 "->" n2
endfor
endfunction
" autocmd BufNewFile,BufRead *.php,*.blade.php set filetype=php
" autocmd BufEnter * nested :call tagbar#autoopen(0)
autocmd FileType * :lua nukevim.modules:get('keymap'):registerBufferLocal()
" Disable whitespace highlighting in startup screen
autocmd FileType startup setlocal nolist
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Netrw key mappings
" Special case for mapping ctrl l/r in netrw since it already has those bound
" to stuff I don't use.
augroup netrw_mapping
autocmd!
autocmd filetype netrw call NetrwMapping()
augroup END
function! NetrwMapping()
noremap <buffer> <C-H> :tabprev<CR>
noremap <buffer> <C-L> :tabnext<CR>
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Terminals
" Some junk to make the terminal buffers exist when the underlying app exits.
" Get the exit status from a terminal buffer by looking for a line near the end
" of the buffer with the format, '[Process exited ?]'.
func! s:getExitStatus() abort
let ln = line('$')
" The terminal buffer includes several empty lines after the 'Process exited'
" line that need to be skipped over.
while ln >= 1
let l = getline(ln)
let ln -= 1
let exitCode = substitute(l, '^\[Process exited \([0-9]\+\)\]$', '\1', '')
if l != '' && l == exitCode
" The pattern did not match, and the line was not empty. It looks like
" there is no process exit message in this buffer.
break
elseif exitCode != ''
return str2nr(exitCode)
endif
endwhile
return 255
" throw 'Could not determine exit status for buffer, ' . expand('%')
endfunc
func! s:afterTermClose() abort
if s:getExitStatus() == 0
bdelete!
endif
endfunc
augroup terminal
autocmd!
" The line '[Process exited ?]' is appended to the terminal buffer after the
" `TermClose` event. So we use a timer to wait a few milliseconds to read the
" exit status. Setting the timer to 0 or 1 ms is not sufficient; 20 ms seems
" to work for me.
autocmd TermClose * call timer_start(20, { -> s:afterTermClose() })
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-commentary
" Map Ctrl+/ in visual mode to toggle block comments with vim-commentary
:vmap  gc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" coc
" `K` shows method signature/documentation
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
nnoremap <silent> K :call <SID>show_documentation()<CR>
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Merge the signal column (your shit broke, yo') into the number column,
" or if not supported at least show it all the time so the whole text
" isn't constantly shifting as errors appear/disappear.
if has("patch-8.1.1564")
set signcolumn=number
else
set signcolumn=yes
endif
Loading…
Cancel
Save