Chapter 29. What tools provide what functions?
-
python-mode
works automatically when in python-mode
-
python-ts-mode
No difference apparent vs python-mode (over my body)
-
treesitter
In Emacs, with python file open (but cursor anywhere), type
C-c TAB s
Prerequisite
Requires python isort package.
poetry add --group=dev isort
This works, but the exact details conflict with ruff's linter and produce an
I1001
error. -
ruff
At the command line:
ruff check
filename
--fix
-
LSP and pylsp
Put cursor in symbol.
M-x lsp-rename
-
treesitter
To use treesitter, first change to the -ts- version of the current mode. For example,
python-ts-mode
instead ofpython-mode
. To make this automatic TK.If needed, install the grammar for that mode via
M-x treesit-install-language-grammar
and then following the prompts to let it download and compile and install the grammar. -
lsp
?
-
lsp + yasnippet
?
Installation
Add to
~/.emacs.d/init.el
:(usepackage yasnippet)
-
treesit + treesit-fold
stuck on this error:
Symbol’s function definition is void: treesit-fold-indicators-refresh Mark set
Note
Installed via Manual method:
git clone https://github.com/emacs-tree-sitter/treesit-fold /path/to/lib
and then putting this in
~/.emacs/init.el
:(use-package treesit-fold :load-path "/path/to/lib")
Raw notes
see also https://www.mattduck.com/lsp-python-getting-started.html
Completion Front-ends
helm
ivy
default
linting from flycheck (UI) + ruff
Install ruff
------------
poetry add --group=dev ruff
poetry add --group=dev flycheck
Commands
--------
Things I want to do
* rename symbols
-
* replace tabs with spaces and switch to two spaces
* figure out what lens mode does
-
Functional Requirements
Code navigation
jump to definition
see usages
fold/unfold
move cursor by semantic increments
Reformatting
exact format (black)
module order (isort)
Refactoring
renaming symbols
-
What does what
Table 29.1. Front and back end providers by functionLSP Server Lint Type check autocomplete Navigate Reformat Test + Debug Refactor Doc python-lsp-server ◒ ruff server ◒ Front End flycheck ◓ ◓ eglot ◓ eglot-rename
lsp-mode ◓ eglot-rename
LSP ● ruff (as LSP) ● company ● black ◐ isort ◐
Note
◓: Provides UI
◒: Provides back end
◐: Provides some functions
⚫: Provides everything