Skip to content

deomorxsy/deorice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deorice

dotfiles for *nix setup ricing

Lua Neovim

PS: For any interested readers, try to create your own configuration based on these dotfiles.

PS2: Some of these are related with neovim running under tmux.

PS3: The following is not intended to be gatekeeping how to use any of these tools. Its just a merge between a personal opinionated configuration and a tutorial for posterity.

Editors

vim

The config is pretty straight-forward: just edit the ~/.vimrc with vimscript/vimL syntax, place it in $HOME and next time you open vim it is already working. Search for the basics: the 7 vim modes, vimscript syntax, commands, etc. Read the errors and try to find the root cause. It's the best way to get out of future possible circles of the dependency hell.

neovim

Neovim adopts the ~/.config/nvim/init.vim or ~/.config/nvim/init.lua file as the default config file. It is also compatible with the vimrc; that explains the source. It means these are the files neovim uses for configuration lookups every time the editor starts.

This repository in specific migrates from the vimrc, used in vim, directly to the init.lua that uses the syntax of the language lua to program the editor. The runtime is the LuaJIT embedded in neovim and you can learn more in the docs.

To handle LSP, DAP, linters and formatters you can use mason-nvim. You can also integrate its functionality with lsp-zero into a not-bloated, fast gattai-mecha for completion.

To use the base configuration, run the playbooks, execute the scripts or do it manually:

  1. Clone this repository:
git clone [email protected]:deomorxsy/deorice.git
cd ./deorice/
  1. Copy nvim to the $HOME config dotfile:
cp -r ./.config/nvim/ ~/.config/
  1. Clone packer.
git clone --depth 1 https://github.com/wbthomason/packer.nvim \
 ~/.local/share/nvim/site/pack/packer/start/packer.nvim
  1. To avoid provider-related errors, specifically about python (ultisnips), you can use the script neovim-setup.sh, ./scripts/neovim-setup.sh, which sets up the python provider $PATH based in the hack path that python uses with the virtualenv, adapted from the docs ;)
cat > ./scripts/neovim-setup.sh << "EOF"
#!/usr/bin/sh
#
# packer plugin manager setup
git clone --depth 1 https://github.com/wbthomason/packer.nvim \
 ~/.local/share/nvim/site/pack/packer/start/packer.nvim

# setup python venv
python3 -m venv ~/.config/nvim/venv_nvim/neovim3

# source the venv activate binary
. ~/.config/nvim/venv_nvim/neovim3/bin/activate
python3 -m pip install --upgrade pynvim==0.5.0

# returns the relative $PATH of the python binary installed on the virtualenv
pyvm=$(which python)

# checks if the placeholder exists on file
roco=$(awk 'FNR==14 && $3==p3hp_placeholder' "$HOME/.config/nvim/init.lua")

# using @ as sed delimiter since the bash variable expansion already uses
# the slash "/" character for the path
[ -n "$roco" ] && sed -e "s@p3hp_placeholder@$pyvm@g" "$HOME/.config/nvim/init.lua"

# deactivate virtualenv
deactivate
EOF

chmod +x ./scripts/neovim-setup.sh
. ./scripts/neovim-setup.sh
  1. Set the python provider path
let g:python3_host_prog = "${HOME}/.config/nvim/venv_nvim/neovim3/bin/python"
  1. Source the packer.lua file to finish installing packer. Then, also in command line, synchronize plugins in the configuration with packer. I like the headless flag for this, otherwise just open the specific packer.lua file for sourcing, enter Terminal Mode and type :so. Synchronize with PackerSync in any context.
nvim --headless -c 'so' -c 'PackerSync' "${HOME}/.config/nvim/lua/user/packer.lua"

Main plugins used in this vim/neovim rice, not ordered:

  • telescope or chadtree for fuzzy search. The second is a whole completion client spawning sqlite vms in memory and integrating with other external programs;
  • nvim-R to run a R interpreter inside neovim (checkout the tmux integration);
  • vimtex for latex local editions;
  • lsp-zero as a Language Server Protocols manager (literally acts as a package manager), which are external to neovim;
  • mason.nvim as a package manager for LSP servers, DAP servers, linters, and formatters;
  • nvim-treesitter to parse all the code in the editor. It builds an incremental parsing tree that is useful for a bunch of tasks related to programming language constructs, like highlighting, indenting, folding of these constructs, text-object manipulation and others. Also fast af;
  • presence.nvim is a cool way to understand how activity logic SDKs such as discord presence works, and also lua dotfile config for other apps.
  • pio for espressif development. Install it also on the virtualenv, use it inside nvim or source outside while multiplexing with tmux. Also check xtensa-qemetsu for a CI/CD, qemu-based environment setup.