NEWTON
Asked
6 months ago
133
views
1
Hi! I like writing my Cairo code in vim. However, I don't like that Cairo lang code has no auto-format and syntax highlighting (see screenshot):
I'm looking for a plugin to write Cairo contracts on Starknet in vim with all pretty formatting. Can you recommend any and how to install it as well?
vargastartup
asked
6 months ago
2
Accepted answer
Yes! I wrote a Vim plugin for Cairo, it's fully updated for Cairo v0.10.0 syntax too.
https://github.com/0xHyoga/starknet-vim
To get the full power of Starknet-Vim I recommend using vim-ale and universal c-tags. If you check out the starknet-vim repository there's a section on how to install these.
1-- Asynchronous linting
2-- Syntax highlighting
3-- Auto-format with <C-y>
4--c-tags to show the file functions according to decorators (storage_vars, events, view, external, etc.)
Here is a small demo of starknet-vim
To change keybinding for auto-format just edit ftplugin/cairo.vim
function! CairoFormat()
silent !clear
silent execute "!cairo-format -i " . bufname('%') | execute ':redraw!'
endfunction
command! CairoFormat :call CairoFormat()
nnoremap** <C-y> **:call CairoFormat() <CR>
Note: This is a work in progress. I am updating it as i go deeper into the Cairo rabbit hole ;)
Any questions feel free to ask!
Anubis
answered
6 months ago
0
Hey, I found one more vim extension for starknet/cairo by 0xAurelou. This plugin supports vim Syntax for cairo v0.10 and hopefully Cairo 1.0 will be supported as well. https://github.com/0xAurelou/cairo_vim
The installation instruction
Just copy paste this in your
~/.vim/syntax/cairo.vim
Be sure you have this lines in your .vimrc
"Add Cairo Support
au BufReadPost *.cairo set filetype=cairo
au Filetype cairo set syntax=cairo
Newton
answered
4 months ago
A plan to get better visibility when a transaction got received but not placed into a block?
StarknetPy Error in get_balance_sync (StarknetErrorCode.ENTRY_POINT_NOT_FOUND_IN_CONTRACT)
Checking result of an L1 -> L2 message/invoke in Starknet
Does Cairo work in python3.10 venv? I can’t install python 3.9
Declaring a StarkNet contract on DevNet with Account() but I get GatewayError in StarkNetJS
How to install Cairo v0.10.0 on my device?
What is SHARP in Cairo Language?
Is starknet.id legit?
How to modify keccak.cairo and/or packed_keccak.cairo to compute a 512bits keccak hash instead of 256 bits?
Trying to deploy contract with Argent guide but got error Unitialized Contract
What does ret do in Cairo?
What’s the difference between Account Abstraction (AA) and Externally Owned Accounts (EOA)?
Warp Traspiler error: the warp-related package was not found. How do I generate python packages?
Will it be possible to invoke functions from within the loops in Cairo 1.0?