| HackerNews | reddit |
Focus on the important parts of the code. Hide the rest, literally. With Yode-Nvim you can go deeper than the file level, picking out the lines that are important for the current task. Whether you want to focus on important parts of a large file, or collect small parts of many files, you can see everything at a glance. Zoom from the focused part back into the file to briefly expand your context or adjust your focus. Everything happens in the editor, the rest of the tool chain still works, this makes Yode-Nvim work for any programming language, framework, etc.
For the past six months, I've been using this MVP in its various stages in development for Yode-Nvim itself. Currently I am working on fixing minor bugs and integrating more plugins.
For a more in-depth introduction to the idea of Yode, check out the video of the proof of concept!
Neomake error linting with correct error placement:
yode-nvim-gifs-neomake.mp4
Code formatter changes file buffer and seditor:
yode-nvim-gifs-formatting.mp4
Gread to restore file with git:
yode-nvim-gifs-gread.mp4
YodeCreateSeditorFloatingfocus on a code part and make it floating, stay at the current (main) viewYodeCreateSeditorReplacefocus on a code part and replace it with the current bufferYodeBufferDeletedelete the current buffer and jump back to file, if it is a seditorYodeGoToAlternateBufferYode-Nvim creates buffer local mappings for these commands, seelua/yode-nvim/createSeditor.luafor all mappingsYodeCloneCurrentIntoFloatclone seditor into floatYodeFloatToMainWindowis the oppositeYodeFormatWriteformats and writes a buffer, no matter which typeYodeRunInFilecan run a command in the current file or the file buffer of the current seditor- changes from outside are tried to be applied as good as possible. If this does not work so well, seditors can change the size
- in general there are different layouts for the floating windows, but at the moment there is only one
- jump between windows by using
<C-W>wor have a deeper look at window movement - see the next section for more details
You need at least Neovim 0.6. Add Plenary and Yode-Nvim to your config, e.g. with vim-plug:
Plug 'nvim-lua/plenary.nvim'
Plug 'hoschi/yode-nvim'Important is that this repo is cloned with submodules, which happens automatically when you use vim-plug. The minimal setup is this:
lua require('yode-nvim').setup({})Check out the help section for a more sophisticated configuration.
TODO move this to Vim help syntax ./doc/yode-nvim.txt.
kdheepak/panvimdoc: Write documentation in pandoc markdown. Generate documentation in vimdoc.
- install
- use your favorite plugin manager, important is to include the git submodules
- clone with submodules:
git clone --recurse-submodules git@github.com:hoschi/yode-nvim.git
- log is written to cache dir of
stdpaths- the default level is 'warn', but can be configured. Level can also be overwritten with an environment variable, see the Development section for more info.
- TODO link here how to echo this dir
- e.g.
~/myuser/.cache/nvim/yode-nvim.log
- example setup:
lua require('yode-nvim').setup({})
map <Leader>yc :YodeCreateSeditorFloating<CR>
map <Leader>yr :YodeCreateSeditorReplace<CR>
nmap <Leader>bd :YodeBufferDelete<cr>
imap <Leader>bd <esc>:YodeBufferDelete<cr>
" these commands fall back to overwritten keys when cursor is in split window
map <C-W>r :YodeLayoutShiftWinDown<CR>
map <C-W>R :YodeLayoutShiftWinUp<CR>
map <C-W>J :YodeLayoutShiftWinBottom<CR>
map <C-W>K :YodeLayoutShiftWinTop<CR>
" at the moment this is needed to have no gap for floating windows
set showtabline=2- compatible plugins with current change detection logic
- tpope/vim-fugitive: fugitive.vim: A Git wrapper so awesome, it should be illegal
Greadworks by using one or two change events
- tpope/vim-fugitive: fugitive.vim: A Git wrapper so awesome, it should be illegal
YodeRunInFileworks only with synchronous commands, e.g.Gread. Not with async commands likeFormatWrite- adapted plugins
- mhartington/formatter.nvim
- uses
nvim_buf_set_linesfor onechange/addevent, but is async - adapted version to install
- uses
- neomake/neomake: Asynchronous linting and make framework for Neovim/Vim
- uses API methods of
api.luato be aware of file vs seditor buffers - adapted version to install
- uses API methods of
- mhartington/formatter.nvim
- overlapping/nested seditors are not supported at the moment
- see TODO statements in
onSeditorBufferLines - other parts of code as well, probably not documented
- see TODO statements in
Integration with the LSP client to be able to use all the features in seditors as well is definitely one of my top priorities. Contributions that improve the collaboration with the rest of the NeoVim universe would help a lot. The integration of Neomake and Formatter.nvim can be taken as examples. Other plugins may be easier to integrate, check this ticket: Collection of tips to get Yode-Nvim working with other plugins
- Lamda module help
- start Neovim with
DEBUG_YODE='debug' nvimto set log level- TODO link to modes
- "trace" shows state changes as well
- see log file:
tail -f ~/.cache/nvim/yode-nvim.log | grep -v "^\["- last part removes the file name lines
- format files
- install
stylua make format
- install
- lint files
- install
luacheck make lint
- install
- see
local.vimrcfor enhancements- rename to
.local.vimrcto use it - install nvim plugin for it
- start Neovim with
YODE=true DEBUG_YODE='debug' nvimto enable special parts for testing
- rename to
- install local Lua
- install Hererocks
- setup environment with
hererocks env -l5.1 -rlatest - source environment with
source env/bin/activate - install packages you want to use in REPL, e.g.
luarocks install inspect
- REPL
- source environment as showed above
cd luato go into the same path Neovim saves Lua files- start a REPL with
lua - require installed luarocks packages, e.g.
inspect = require('inspect') - require local deps by copy/paste from source, e.g.
R = require('yode-nvim.deps.lamda.dist.lamda') - require source code, e.g.
h = require('yode-nvim.helper') - play with the code which works, everything using
vim.XYZwill fail
- test JS development
npm cito install dependencies- now you can setup Neomake for the JS files in
testData/
- run tests:
- running tests requires plenary.nvim to be checked out in the parent directory of this repository
- run all tests:
make test - run single test:
nvim --headless -c "PlenaryBustedDirectory lua/yode-nvim/tests/e2e/seditor_to_file_editor_sync_spec.lua {minimal_init = 'lua/yode-nvim/tests/minimal.vim'}" - more infos, see Plenary docs here
- run all tests on file changes
nodemon -e lua,vim --exec 'make test' - run single test on file changes
nodemon -e lua,vim --exec "nvim --headless -c \"PlenaryBustedDirectory lua/yode-nvim/tests/e2e/basic_mosaic_layout_spec.lua {minimal_init = 'lua/yode-nvim/tests/minimal.vim'}\" " - run single test file and log
DEBUG_YODE='trace' nvim --headless -c "PlenaryBustedDirectory lua/yode-nvim/tests/e2e/recover_seditor_with_undo_spec.lua {minimal_init = 'lua/yode-nvim/tests/minimal.vim'}"