A repo that I'm using to learn vim/neovim.
Just formatted this
README
and added this line vianeovim
. Massive flex :O
You can find my 2 configs in coc version and lsp version
Press
i
to enterinsert mode
.
Press
escape
to exit current mode.
This lets you actually make changes to your files. Until then it's all read-only. Good to read through some code without worrying about accidental changes.
Creating and opening files:
# while in the directory you want to work in
nvim nameoffile.extension
Creates or opens the file specified depending on it's existence on disk.
Opening entire director:
nvim .
Opens and displays a file browser that you can naviagate through. Press enter
to open file. Neat out-of-the-box feature.
While in your default working directory. Create/Access the .config
folder. This usually already exists so beware.
mkdir .config
cd .config/
Make a nvim
directory:
mkdir nvim
Create neovim config file:
nvim init.vim
My current config will be added to this repo
:set number
:set relativenumber
:set autoindent
:set tabstop=4
:set shiftwidth=4
:set smarttab
:set softtabstop=4
:set mouse=a
I am using vim-plug for this. Follow install instructions from there.
Setting up vim-plug
requires adding the following to the init.vim
file:
call plug#begin()
" all your plugins...
Plug 'url to your plugin'
call plug#end()
Also install exuberant ctags
brew install ctags
Installing the Plugins (One time only)
Inside your nvim instance run the following in command mode:
:PlugInstall
Your plugins are now installed!
Deleting plugins:
Remove the
Plug ''
entry from theinit.vim
file.
Run
:PlugClean
.
For autocompletions.
After adding the Plug config:
Plugin 'neoclide/coc.nvim'
Go to your plugged
folder.
On Mac: ~/.local/share/nvim/plugged
.
On Linux: ~/.config/nvim/plugged
.
cd coc.vim/
yarn
This installs all dependencies. Takes a while.
Install using:
:CocInstall name-of-lsp
-
Python:
coc-pyright
. -
JSON:
coc-json
. -
Markdown:
coc-markdownlint
. -
JS/TS:
coc-tsserver
. -
HTML:
coc-html
. -
Java:
coc-java
. -
CSS:
coc-css
. -
Dart:
coc-flutter
. -
Bash:
coc-sh
. -
prettier:
coc-prettier
.
:checkhealth
Use :u
and :r
respectively.
In command
mode. Press / to enter search. Now type a regex pattern you would like to search.
Clear the selections by using :noh
.
To select any text, you must enter visual
mode. Press v in normal
mode for this.
-
Use arrow keys to expand the selection.
-
d Deletes the selection.
-
y "yank"/copy the selection.
-
p Paste the selection.
-
Search by using these 4 in conjuntion on the selected text: y q / p
-
r Replace selection with text you will now type.
Use: " + y and " + p from visual
mode.
-
Ctrl W S (upper case) for horizontal splitting
-
Ctrl W v (lower case) for vertical splitting
-
Ctrl W Q to close one
-
Ctrl W Ctrl+W to switch between windows
-
Ctrl W J (x or K, H, L) to switch to adjacent window (intuitively up, down, left, right)
-
Create a
lua
directory under.config/nvim/
. -
Create another subdirectory under
lua
. Use your name for example. -
Write all your scripts here. Ex:
options.lua
. -
At the
nvim/lua
directory level create aconfig.lua
and inside that add references to all subdirectory contained lua scripts with:
require "example_subdir.option"
In your init.vim
load the script with:
lua require('config')
After tinkering with coc, which is easier to get started with, I realized I need greater granular control over my configs while also keeping them light weight. So I'm switching to the native LSP.
Add the nvim-lspconfig
plugin.
Plug 'neovim/nvim-lspconfig'
-
Python:
yarn global add pyright
-
JS/TS:
yarn global add typescript typescript-language-server
# macOS or Linux
brew install glow
# macOS (with MacPorts)
sudo port install glow
# Arch Linux (btw)
pacman -S glow
# Void Linux
xbps-install -S glow
# Nix
nix-env -iA nixpkgs.glow
# FreeBSD
pkg install glow
# Solus
eopkg install glow
# Windows (with Scoop)
scoop install glow
# Android (with termux)
pkg install glow
Plug 'ellisonleao/glow.nvim', {'branch': 'main'}
You need ripgrep
for live_grep
.
brew install ripgrep
brew install jq
Install gopls
after adding gopls
to your LSPConfig.
brew install gopls
brew install ripgrep
brew install gnu-sed
brew install lazygit
For remote development (access files on remote machine).
brew install sshfs