NEWTON
Asked
4 months ago
128
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
4 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
4 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
1 month 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?
Can anyone point me to Pedersen, Rescue references? StarkNet / Cairo Lang
Does Cairo support int256, or negative numbers in general?
How can I use start_prank with deploy_contract?
What are function argument types in starknet.js?
Implicit Arguments in Cairo
Implementing the connect wallet. Can you help about connectors?
How long does starkgate bridge process?