Switch to neovim
's native LSP client.
lsp-zero.nvim
can be a staring
point.
Run install.sh
. After that, if you are not using zsh
, you may want to restart your session.
Also, you may need to do source reload.sh
to reload settings.
Note we create symlinks instead of hard copies. If one configuration file already exists, it will be backed up.
The backup file will be saved in ~/.dotfiles_backup
.
All configurations are light so that they work on new machines.
However, if you don't have some basic programs like zsh
, git
, python
curl
installed,
you may need root privilege to install these programs.
Copy the following to ~/.local/bin/proxy
:
#!/bin/bash
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
$@
Then
chmod u+x ~/.local/bin/proxy
tldr
: quickly figure out the usage of most commandsautojump
: jump to recently visited locationsnnn
: interactive terminal navigator. Supports cd on quit with<ctrl+g>
htop
: interactive topfzf
: fuzzy file finder, and improves command line reverse search.gpustat
: monitor gpu usage. Way better thannvidia-smi
ripgrep
: bestgrep
toolrclone
: command line tool for managing cloud filespsync
:rsync
project files with a configuration file. If you see yaml issues you can directly modify the source file.git difftool --tool=vimdiff
- rsync semantics with slash: https://stackoverflow.com/a/31278462
- Basically only slash at the end of src has a major effect. For the destination, it makes a difference only when the (1) src is a file (2) dst is non-existent
- rsync delete related: https://superuser.com/a/1513723
- You can setup ssh to reuse established ssh channels: https://unix.stackexchange.com/questions/33557/using-an-already-established-ssh-channel
Settings -> Profiles -> Keys -> General
, set left option key to beEsc +
Settings -> Profiles -> Keys -> Key Mapping
, make^/
send0x1f
. This is used for commenting.
- vim: molokai
- iterm2: default
The final solution is
ale
+[flake8, pylint]
for linting. I didn't usevim-lsp
becauseale
provides more fine-grained error highlighting whilevim-lsp
imply highlights the whole line.flake8
with plugins is very complete, but limited because it checks each file individually.pylint
is for errors like invalid imports, invalid members and invalid arguments.vim-lsp
for the language server protocal client. It is the only one that supports popup for signature help. Otherwisevim-lsc
is also good.jedi-language-server
for the language server protocal server. It is the only one that (currently) supports workspace symbol search. And it is lightweight.black
for code formatting. This is combined with vim's nativegq
(seehelp gq
).
You need to install jedi-language-server
to support vim-lsp
. With
vim-lsp-settings
, you only need this:
:LspInstallServer jedi-language-server
The server will be installed in $HOME/.local/share/servers
. Note that
jedi-language-server
is aware of your virtual environment, and handles system
paths correctly.
vim-lsp-settings
allows per-project configuration. See
:LspSettingsLocalEdit
. I guess it can find the settings because of the
automatic root guess. This allows sending project specific configurations to the
servers, by changing the registered information.
To enable linting and fixing in vim, install flake8
, yapf
and pylint
pip install flake8
pip install pylint
pip install black
Note, you should install pylint
under the virtual environment you want to get
correct behavior. It is not aware of the virtual environment. It checks the
imported module files. In contrast flake8
checks files individually. It
doesn't care about whether the imported module exists or a member exists so it
is fine to install it globally.
Recommended flake8 plugins:
pip install flake8-unused-arguments
pip install flake8-todo
pip install flake8-multiline-containers
pyflakes
checks each file individually. So there's no need to worry about paths.
pylint
: we only consider the case where a path to a python file is given.
Eventually, it is translated into a source root, and a set of fully qualified
module names. Example
a
├── b
│ ├── __init__.py
│ └── c
│ ├── __init__.py
│ └── hihi.py
└── haha.py
And assume pylint hihi.py
.
The translation is done as follows:
- Expand the path given into absolute path. Yes, the current working directory is not used at all.
- Determine the source root: starting from bottom, the first directory that
does NOT contain
__init__.py
is seen as the project root. In the above,a
is the source root. - The source root is added to the "virtual"
sys.path
for checking imports. - The fully qualified module name is from the source root. I.e.
b.c.hihi
.
Besides, pylint
is not aware of virtual environment. So, you have to install
it in the virtual environment you want.
At startup, LSP clients send a request to LSP servers for connection. The
request contains a rootUri
attributes that states the workspace root. This
root is used for workspace symbol search etc.
So, the LSP client determines the root. vim-lsp
provides a registration
function that takes a lambda for the root. vim-lsp-settings
call that function
provides the actual lambda that computes the root. The root is the nearest
directory that contains one of the "markers" (e.g., .git/
). If no such markers
exist, the root seems to be set to be the cwd or the directory containing the
current file (not sure).
jedi-language-server
uses the root to give suggestions on imports. It seems it
adds some of the intermediate paths from the project root to the virtual
sys.path
, instead only adding the root. The actual rule is still unclear.
Seems to be due to smart_sys_path
here. The
actual rule seems to be defined
here.
Relative imports behave normally though.
It is aware of the virtual environment. So it doesn't matter which
jedi-language-server
you can calling.