I'm writing code in a language called choicescript, and it defines global variables like so:
*create <variable name> <initial value>
Global variables are defined only in a single file named startup.txt, and their scope is all files in the project.
Local variables are defined like so:
*temp <variable name> <initial value>
Their scope is only the file in which they're defined.
Examples of variables being used in the code:
*temp str "Dogs"
*set str "Cats"
I like ${str} the most.
*if (str = "Dogs")
I like dogs the most.
Choicescript also has labels for the *goto command. Example:
*if str = "Dogs"
*goto dogs
*label dogs
Some text about dogs here.
Scope of labels is the file in which they're defined.
What I'd like to be able to do is for Vim to maintain a list of variables and labels for autocompletion. How can I set this up?
Here's the syntax file I created (which is still doesn't contain folding and is still a work in progress since my Vim experience is still noob level):
if exists("b:current_syntax")
finish
endif
let b:current_syntax = "choicescript"
setlocal iskeyword+=#
setlocal iskeyword+=*
set breakindent
syntax match csOption '#.*$'
syntax keyword csCond *if *else *elseif *elsif *selectable_if
syntax keyword csRare *delete *allow_reuse *goto_random_scene *share_this_game *link *more_games *print *script *check_achievements
syntax keyword csGoto *ending *finish *gosub *gosub_scene *goto_scene *goto *gotoref *return
syntax keyword csChoice *choice *fake_choice
syntax keyword csReuse *disable_reuse *hide_reuse
syntax keyword csSet *create *temp *set *setref
syntax keyword csOther *input_text *input_number *image *line_break *page_break *rand *stat_chart *achieve *achievement
syntax keyword csLabel *label
syntax match csComment '^\s*\*comment.*$'
hi def link csOption Special
hi def link csCond Statement
hi def link csRare Todo
hi def link csGoto Constant
hi def link csChoice Identifier
hi def link csReuse Type
hi def link csSet Keyword
hi def link csOther PreProc
hi def link csLabel Function
hi def link csComment Comment
hi Comment guifg=green gui=italic
hi Identifier gui=bold
hi Constant gui=bold
hi Statement guifg=blue
hi Function guifg=orange gui=bold
hi Keyword guifg=maroon gui=bold
hi Special gui=bold
:help complete-functions
./usr/share/vim/vim74/autoload
.