A tailored Micro Editor for Python development
This are a set of several files, tips and recommendations using Micro while developing in Python.
Micro currently can highlight more than 100 languages and users can customize their editor with several methods. Although the repository counts with several syntax files, and it's stated how can be improved to better suit the user experience, at the present it addresses general group statements and keywords. Thus the expanded syntax file present here adds type hint, function calls and several other new handy highlighted cases. This isn't by any means a full fledged error prove file: either by current Micro limitations, statement overruling, missing regex statements (or isn't specific enough) some words might not be highlighted as expected (i.e urls).
Present color schemes are designed to comply with the syntax file. Custom color schemes should follow the same rules in order to work properly. Both files contain commentary enough explaining which command is responsible for the specific color scheme. For instance darcula.micro in this repository extends/modifies the original color scheme in vanilla Micro to adjust for the new statements.
Several simple lines of code which encompasses the most common highlighted cases for fast checking or test.
Although the present files are specific for Python, the overall code template present in here for both syntax and color scheme can be adjusted to meet the specifics of any other language. Refer to the Micro syntax repository if the language is already supported and modify it as desired.
- Python 3 installed
- Either conda, venv or any tool for environment setup (recommended)
-
Create a new Python environment and activate it. (optional but recommended)*
-
git clone [email protected]:EllKyGr/Pycro.git
thenmake
make u-pycro
removes all Pycro related files, i.e. all color schemes within this repository and the python3.yaml. NOTE: although several color schemes are extended versions of default ones, you can still use them throughset
command or added directly to thesettings.json
after deleting the extended version. If a Micro session is open during removal process, exit once deleted, thenreload
to use default version, assuming the current colorscheme matches the same file name.make u-micro
removes all Pycro and Micro related files from your system. NOTE: if your Micro bin is located anywhere but /usr/bin this command won't be able to delete it.- After the setup is complete you can run
make clean
to remove this repository since its content will no longer be necessary. The makefile would be relocated to the parent directory so the previous commands are available. If deleted the removal of Pycro (and/ or Micro) should be perform manually. Refer to the step by step section if that's the case.
- Install git then shasum with
pkg install perl
git clone [email protected]:EllKyGr/Pycro.git
- Open the makefile and change (-)
micro: checksum - cd /usr/bin/; echo "\nInstalling Micro at => $$PWD\n"; \ + cd /data/data/com.termux/files/usr/bin/; echo "\nInstalling Micro at => $$PWD\n"; \ - curl https://getmic.ro | sudo bash; + curl https://getmic.ro | bash;
- Then
make
. The same commands apply to remove Pycro files and Micro however to remove Micro throughmake u-micro
, the following line should be changed:u-micro: - cd /usr/bin; echo "Attempting to remove Micro from $$PWD"; sudo rm -i micro; \ + cd /data/data/com.termux/files/usr/bin; echo "Attempting to remove Micro from $$PWD"; rm -i micro; \
- Although not necessary for the present settings, be aware of the micro bin file location. (The makefile can only remove Micro entirely if located at /usr/bin)
- Create a new Python environment and activate it. (optional but recommended)*
git clone [email protected]:EllKyGr/Pycro.git
thenmake pycro
* The main reason for using a Python environment is just for containment sake. On the other hand the plugins related to this packages will not work as intended if the latter are missing. Meaning to use Micro's full capacity (while developing Python) these two packages should be present.
-
Installing Micro:
- Micro 2.0.XX => https://github.com/benweissmann/getmic.ro
- Add to
~/.config/micro/syntax/
thepython3.yaml
after installing Micro. - Add to
~/.config/micro/colorschemes/
thecolor_scheme_file.micro
either from here, the Micro repo or a custom one. - Optional: create a Python environment with your favorite tool before proceeding.
-
Plugins
micro -plugin install <plugin>
:-
aspell
: spell checking.addpersonal
adds word to personal dictionary when cursor is placed under said word. -
filemanager
: adds a tree to visualize, open, create files and directories:Ctrl + e
thentree
: open the file treeleft key
orright key
: closes or collapses the directoryrename
: new name for selected file inside treerm
: deletes file inside treetouch
: creates file in the current pathmkdir
: creates directory in current path
-
lsp
: adds language server for better coding style and formatting- Run
pip install python-lsp-server
for the lsp plugin to work Alt + d
: with cursor under a function returns the documentationAlt + k
: with cursor under function, object, etc returns brief description at status lineCtrl + _
: comments out the line. Repeat to undo previous actionCtrl + space
: limited auto complete; all possible keywords are listed yet not cleanly stated
- Run
-
autofmt
: formats file content at save based on language. Until the current autofmt repository is updated with a-plugin
command, do this instead:git clone [email protected]:a11ce/micro-autofmt.git
cd
to micro-autofmt/ thenmake
. The cloned repository is no longer needed after installing the plugin files so it can be removed aftewards.- Currently only C/C++/C#, Python, Racket, JavaScript, Rust and Go are supported. Every language require its specific formatter
- For Python run:
pip install git+https://github.com/google/yapf.git
either directly or within environment.
-
runit
: allows to run, compile and make files on the go.F5
: saves and runF12
: makesF5
: makes in the background
-
manipulator
: add commands inside Micro for alternative edition, i.e.Ctrl + e
followed by:dquote
wraps selected text within double quotescurly
wraps selected text within {}camel
turns text into camelCase format
NOTE: Refer to the main page of the repository, or the manipulator.md after installed, to learn all the available commands. The plugin installs version 1.4.0, version 1.4.1 is needed for
camel, snake, kebab
, etc to work otherwise Micro won't recognize them. -
quoter
: wraps the lines with double or single quotes. -
cheat
: pressingF1
opens a new tab with a cheatsheet of concepts from the current working language. Although mostly basic concepts of the language, the file can be modify and expand upon as needed.
NOTE: the path stated in main.lua at line 11 => local cheatdir = config.ConfigDir.."/plug/micro-cheat/cheatsheets/" conflicts with the actual path installed for the plugin, instead of micro-cheat change it to cheat -
snippets
: adds vim like snippets capabilities to Micro, i.e. right nextdef
:Alt + s
: inserts the snippetAlt + w
: toggle between elements from the snippetAlt + d
: removes snippetAlt + a
: exists snippet edition mode
-
-
Settings and key bindings: after installing plugins edit, or create, the
settings.json
at~/.config/micro
with the following options (the lines preceded by # are meant to be deleted):# settings.json { "aspell.check": "on", "aspell.lang": "en", # Native or any language "colorcolumn": 80, # Rule "colorscheme": "darcula", # Or any color scheme fitting the Python syntax file "diffgutter": true, # Visual cue for changes in current file "fmt-onsave": true, # Format on save "hlsearch": true, # Matched letters and background color "hltrailingws": true, # Any type of white space is highlighted "savecursor": true, # Cursor locates in its last position from previous session "scrollbar": true # Optional # lsp plugin will update file with the following options "lsp.ignoreMessages": "LS message1 to ignore|LS message 2 to ignore|...", "lsp.ignoreTriggerCharacters": "completion,signature", "lsp.server": "python=pylsp", } Enter `Ctrl + e` inside Micro and then `set` followed by any additional option you may want in addition to the recommended ones.
Check the Micro options tab for further information
# Expected key bindings in `bindings.json` after plugin install { "Alt-/": "lua:comment.comment", "Alt-a": "lua:snippets.Accept", "Alt-d": "lua:snippets.Cancel", "Alt-f": "command:format", "Alt-k": "command:hover", "Alt-r": "command:references", "Alt-s": "lua:snippets.Insert", "Alt-w": "lua:snippets.Next", "CtrlSpace": "command:lspcompletion", "CtrlUnderscore": "lua:comment.comment", "F1": "command:cheat", "F12": "command:makeup", "F5": "command:runit", "F9": "command:makeupbg" }
Check the Micro keybindings tab for further information
- Add guidelines for windows
- Adapt makefile for windows
- Add new color schemes (at least up to ten)
- Expand and improve syntax file