NEWTON

NEWTON


Popular tags

    Does anyone know a vim plugin for StarkNet smart contracts?

    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):

    https://sun9-86.userapi.com/impg/oNPtr4oks9yNwg3MDoX8c5b-B4IBgK1DARpTbg/RJgXBHR3mEY.jpg?size=1242x682&quality=96&sign=3390ee79c30971ba0dc245122af04905&type=album

    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?

      cairovimstarknet

    vargastartup

    asked

    4 months ago


    2 answers

    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

    Your answer

    NEWTON

    NEWTON