diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/change.txt | 6 | ||||
-rw-r--r-- | runtime/doc/insert.txt | 6 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 95 | ||||
-rw-r--r-- | runtime/doc/options.txt | 10 | ||||
-rw-r--r-- | runtime/doc/various.txt | 4 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 15 | ||||
-rw-r--r-- | runtime/filetype.vim | 3 | ||||
-rw-r--r-- | runtime/ftplugin/julia.vim | 92 | ||||
-rw-r--r-- | runtime/indent/julia.vim | 491 | ||||
-rw-r--r-- | runtime/lua/vim/lsp.lua | 9 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 188 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 6 | ||||
-rw-r--r-- | runtime/syntax/julia.vim | 550 |
13 files changed, 1355 insertions, 120 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 6be87af8a9..aed3acab67 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -986,9 +986,9 @@ inside of strings can change! Also see 'softtabstop' option. > *Y* ["x]Y yank [count] lines [into register x] (synonym for - yy, |linewise|). If you like "Y" to work from the - cursor to the end of line (which is more logical, - but not Vi-compatible) use ":map Y y$". + yy, |linewise|). + *Y-default* + Mapped to "y$" by default. |default-mappings| *zy* ["x]zy{motion} Yank {motion} text [into register x]. Only differs diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index c8a4168ab2..bb00c77ca8 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -68,12 +68,18 @@ CTRL-A Insert previously inserted text. CTRL-W Delete the word before the cursor (see |i_backspacing| about joining lines). See the section "word motions", |word-motions|, for the definition of a word. + *i_CTRL-W-default* + By default, sets a new undo point before deleting. + |default-mappings| *i_CTRL-U* CTRL-U Delete all entered characters before the cursor in the current line. If there are no newly entered characters and 'backspace' is not empty, delete all characters before the cursor in the current line. See |i_backspacing| about joining lines. + *i_CTRL-U-default* + By default, sets a new undo point before deleting. + |default-mappings| *i_CTRL-I* *i_<Tab>* *i_Tab* <Tab> or CTRL-I Insert a tab. If the 'expandtab' option is on, the equivalent number of spaces is inserted (use CTRL-V <Tab> to diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 7e589c095b..4d32be97d3 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -766,15 +766,6 @@ get_log_path() *vim.lsp.get_log_path()* Return: ~ (String) Path to logfile. -init({client}, {bufnr}) *vim.lsp.init()* - client_id → state - - state pending_change?: function that the timer starts to - trigger didChange pending_changes: list of tables with the - pending changesets; for incremental_sync only - use_incremental_sync: bool buffers?: table (bufnr → lines); - for incremental sync only timer?: uv_timer - omnifunc({findstart}, {base}) *vim.lsp.omnifunc()* Implements 'omnifunc' compatible LSP completion. @@ -828,9 +819,9 @@ start_client({config}) *vim.lsp.start_client()* table. Parameters: ~ - {root_dir} (required, string) Directory where - the LSP server will base its rootUri - on initialization. + {root_dir} (string) Directory where the LSP + server will base its rootUri on + initialization. {cmd} (required, string or list treated like |jobstart()|) Base command that initiates the LSP client. @@ -1267,7 +1258,7 @@ enable({bufnr}, {client_id}) *vim.lsp.diagnostic.enable()* the given client. The default is to enable diagnostics for all attached clients. -get({bufnr}, {client_id}) *vim.lsp.diagnostic.get()* +get({bufnr}, {client_id}, {predicate}) *vim.lsp.diagnostic.get()* Return associated diagnostics for bufnr Parameters: ~ @@ -1275,6 +1266,8 @@ get({bufnr}, {client_id}) *vim.lsp.diagnostic.get()* {client_id} number|nil If nil, then return all of the diagnostics. Else, return just the diagnostics associated with the client_id. + {predicate} function|nil Optional function for filtering + diagnostics get_all({client_id}) *vim.lsp.diagnostic.get_all()* Get all diagnostics for clients @@ -1319,18 +1312,18 @@ get_line_diagnostics({bufnr}, {line_nr}, {opts}, {client_id}) Get the diagnostics by line Parameters: ~ - {bufnr} number The buffer number - {line_nr} number The line number - {opts} table|nil Configuration keys - • severity: (DiagnosticSeverity, default nil) - • Only return diagnostics with this - severity. Overrides severity_limit - - • severity_limit: (DiagnosticSeverity, default nil) - • Limit severity of diagnostics found. E.g. - "Warning" means { "Error", "Warning" } - will be valid. - {client_id} number the client id + {bufnr} number|nil The buffer number + {line_nr} number|nil The line number + {opts} table|nil Configuration keys + • severity: (DiagnosticSeverity, default nil) + • Only return diagnostics with this + severity. Overrides severity_limit + + • severity_limit: (DiagnosticSeverity, default nil) + • Limit severity of diagnostics found. + E.g. "Warning" means { "Error", + "Warning" } will be valid. + {client_id|nil} number the client id Return: ~ table Table with map of line number to list of @@ -1665,9 +1658,9 @@ set_virtual_text({diagnostics}, {bufnr}, {client_id}, {diagnostic_ns}, {opts}) E.g. "Warning" means { "Error", "Warning" } will be valid. - *vim.lsp.diagnostic.show_line_diagnostics()* -show_line_diagnostics({opts}, {bufnr}, {line_nr}, {client_id}) - Open a floating window with the diagnostics from {line_nr} + *vim.lsp.diagnostic.show_diagnostics()* +show_diagnostics({opts}, {diagnostics}) + Open a floating window with the provided diagnostics The floating window can be customized with the following highlight groups: > @@ -1679,20 +1672,52 @@ show_line_diagnostics({opts}, {bufnr}, {line_nr}, {client_id}) < Parameters: ~ + {opts} table Configuration table + • show_header (boolean, default true): Show + "Diagnostics:" header + • all opts for + |vim.lsp.util.open_floating_preview()| + can be used here + {diagnostics} table: The diagnostics to display + + Return: ~ + table {popup_bufnr, win_id} + + *vim.lsp.diagnostic.show_line_diagnostics()* +show_line_diagnostics({opts}, {buf_nr}, {line_nr}, {client_id}) + Parameters: ~ {opts} table Configuration table - • show_header (boolean, default true): Show - "Diagnostics:" header. - • Plus all the opts for + • all opts for |vim.lsp.diagnostic.get_line_diagnostics()| - and |vim.lsp.util.open_floating_preview()| - can be used here. - {bufnr} number The buffer number - {line_nr} number The line number + and |show_diagnostics()| can be used here + {buf_nr} number|nil The buffer number + {line_nr} number|nil The line number {client_id} number|nil the client id Return: ~ table {popup_bufnr, win_id} + *vim.lsp.diagnostic.show_position_diagnostics()* +show_position_diagnostics({opts}, {buf_nr}, {position}) + Parameters: ~ + {opts} table|nil Configuration keys + • severity: (DiagnosticSeverity, default nil) + • Only return diagnostics with this + severity. Overrides severity_limit + + • severity_limit: (DiagnosticSeverity, default nil) + • Limit severity of diagnostics found. E.g. + "Warning" means { "Error", "Warning" } + will be valid. + + • all opts for |show_diagnostics()| can be + used here + {buf_nr} number|nil The buffer number + {position} table|nil The (0,0)-indexed position + + Return: ~ + table {popup_bufnr, win_id} + ============================================================================== Lua module: vim.lsp.codelens *lsp-codelens* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index f0ce15ac0f..10b849aa3e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3078,7 +3078,7 @@ A jump table for the options with a short description can be found at |Q_op|. See |help-translated|. *'hidden'* *'hid'* *'nohidden'* *'nohid'* -'hidden' 'hid' boolean (default off) +'hidden' 'hid' boolean (default on) global When off a buffer is unloaded when it is |abandon|ed. When on a buffer becomes hidden when it is |abandon|ed. If the buffer is still @@ -3213,7 +3213,7 @@ A jump table for the options with a short description can be found at |Q_op|. option to a valid keymap name. *'inccommand'* *'icm'* -'inccommand' 'icm' string (default "") +'inccommand' 'icm' string (default "nosplit") global "nosplit": Shows the effects of a command incrementally, as you type. @@ -3498,7 +3498,7 @@ A jump table for the options with a short description can be found at |Q_op|. |jumplist-stack| *'joinspaces'* *'js'* *'nojoinspaces'* *'nojs'* -'joinspaces' 'js' boolean (default on) +'joinspaces' 'js' boolean (default off) global Insert two spaces after a '.', '?' and '!' with a join command. Otherwise only one space is inserted. @@ -6116,7 +6116,7 @@ A jump table for the options with a short description can be found at |Q_op|. specify special kinds of buffers. See |special-buffers|. *'switchbuf'* *'swb'* -'switchbuf' 'swb' string (default "") +'switchbuf' 'swb' string (default "uselast") global This option controls the behavior when switching between buffers. Possible values (comma separated list): @@ -6700,7 +6700,7 @@ A jump table for the options with a short description can be found at |Q_op|. security reasons. *'viewoptions'* *'vop'* -'viewoptions' 'vop' string (default: "folds,options,cursor,curdir") +'viewoptions' 'vop' string (default: "folds,cursor,curdir") global Changes the effect of the |:mkview| command. It is a comma separated list of words. Each word enables saving and restoring something: diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index ec91b6e29a..162909ce45 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -14,6 +14,10 @@ Various commands *various* *CTRL-L* CTRL-L Clears and redraws the screen. The redraw may happen later, after processing typeahead. + *CTRL-L-default* + By default, also clears search highlighting + |:nohlsearch| and updates diffs |:diffupdate|. + |default-mappings| *:mod* *:mode* :mod[e] Clears and redraws the screen. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 2c53620049..166c0c17aa 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -41,9 +41,11 @@ the differences. - 'fillchars' defaults (in effect) to "vert:│,fold:·,sep:│" - 'formatoptions' defaults to "tcqj" - 'fsync' is disabled +- 'hidden' is enabled - 'history' defaults to 10000 (the maximum) - 'hlsearch' is enabled - 'incsearch' is enabled +- 'joinspaces' is disabled - 'langnoremap' is enabled - 'langremap' is disabled - 'laststatus' defaults to 2 (statusline is always shown) @@ -56,12 +58,13 @@ the differences. - 'sidescroll' defaults to 1 - 'smarttab' is enabled - 'startofline' is disabled +- 'switchbuf' defaults to "uselast" - 'tabpagemax' defaults to 50 - 'tags' defaults to "./tags;,tags" - 'ttimeoutlen' defaults to 50 - 'ttyfast' is always set -- 'viewoptions' includes "unix,slash" - 'undodir' defaults to ~/.local/share/nvim/undo (|xdg|), auto-created +- 'viewoptions' includes "unix,slash", excludes "options" - 'viminfo' includes "!" - 'wildmenu' is enabled - 'wildoptions' defaults to "pum,tagfile" @@ -72,6 +75,14 @@ the differences. - |g:vimsyn_embed| defaults to "l" to enable Lua highlighting + +Default Mappings: *default-mappings* + +nnoremap Y y$ +nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L> +inoremap <C-U> <C-G>u<C-U> +inoremap <C-W> <C-G>u<C-W> + ============================================================================== 3. New Features *nvim-features* @@ -150,6 +161,7 @@ Commands: |:drop| is always available |:Man| is available by default, with many improvements such as completion |:sign-define| accepts a `numhl` argument, to highlight the line number + |:match| can be invoked before highlight group is defined Events: |Signal| @@ -167,6 +179,7 @@ Functions: |msgpackdump()|, |msgpackparse()| provide msgpack de/serialization |stdpath()| |system()|, |systemlist()| can run {cmd} directly (without 'shell') + |matchadd()| can be called before highlight group is defined Highlight groups: |highlight-blend| controls blend level for a highlight group diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f012c7cb4b..9c75a49ac1 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -870,6 +870,9 @@ au BufNewFile,BufRead *.ipynb setf json " JSONC au BufNewFile,BufRead *.jsonc setf jsonc +" Julia +au BufNewFile,BufRead *.jl setf julia + " Kixtart au BufNewFile,BufRead *.kix setf kix diff --git a/runtime/ftplugin/julia.vim b/runtime/ftplugin/julia.vim new file mode 100644 index 0000000000..32e364e436 --- /dev/null +++ b/runtime/ftplugin/julia.vim @@ -0,0 +1,92 @@ +" Vim filetype plugin file +" Language: Julia +" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com> +" Homepage: https://github.com/JuliaEditorSupport/julia-vim +" Last Change: 2014 may 29 +" adapted from upstream 2021 Aug 4 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo-=C + +setlocal include=^\\s*\\%(reload\\\|include\\)\\> +setlocal suffixesadd=.jl +setlocal comments=:# +setlocal commentstring=#\ %s +setlocal cinoptions+=#1 +setlocal define=^\\s*macro\\> +setlocal fo-=t fo+=croql + +let b:julia_vim_loaded = 1 + +let b:undo_ftplugin = "setlocal include< suffixesadd< comments< commentstring<" + \ . " define< fo< shiftwidth< expandtab< indentexpr< indentkeys< cinoptions< completefunc<" + \ . " | unlet! b:julia_vim_loaded" + +" MatchIt plugin support +if exists("loaded_matchit") + let b:match_ignorecase = 0 + + " note: begin_keywords must contain all blocks, in order + " for nested-structures-skipping to work properly + " note: 'mutable struct' and 'struct' are defined separately because + " using \? puts the cursor on 'struct' instead of 'mutable' for some reason + let b:julia_begin_keywords = '\%(\.\s*\|@\)\@<!\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\>' + " note: the following regex not only recognizes macros, but also local/global keywords. + " the purpose is recognizing things like `@inline myfunction()` + " or `global myfunction(...)` etc, for matchit and block movement functionality + let s:macro_regex = '\%(@\%([#(]\@!\S\)\+\|\<\%(local\|global\)\)\s\+' + let s:nomacro = '\%(' . s:macro_regex . '\)\@<!' + let s:yesmacro = s:nomacro . '\%('. s:macro_regex . '\)\+' + let b:julia_begin_keywordsm = '\%(' . s:yesmacro . b:julia_begin_keywords . '\)\|' + \ . '\%(' . s:nomacro . b:julia_begin_keywords . '\)' + let b:julia_end_keywords = '\<end\>' + + " note: this function relies heavily on the syntax file + function! JuliaGetMatchWords() + let [l,c] = [line('.'),col('.')] + let attr = synIDattr(synID(l, c, 1),"name") + let c1 = c + while attr == 'juliaMacro' || expand('<cword>') =~# '\<\%(global\|local\)\>' + normal! W + if line('.') > l || col('.') == c1 + call cursor(l, c) + return '' + endif + let attr = synIDattr(synID(l, col('.'), 1),"name") + let c1 = col('.') + endwhile + call cursor(l, c) + if attr == 'juliaConditional' + return b:julia_begin_keywordsm . ':\<\%(elseif\|else\)\>:' . b:julia_end_keywords + elseif attr =~# '\<\%(juliaRepeat\|juliaRepKeyword\)\>' + return b:julia_begin_keywordsm . ':\<\%(break\|continue\)\>:' . b:julia_end_keywords + elseif attr == 'juliaBlKeyword' + return b:julia_begin_keywordsm . ':' . b:julia_end_keywords + elseif attr == 'juliaException' + return b:julia_begin_keywordsm . ':\<\%(catch\|finally\)\>:' . b:julia_end_keywords + endif + return '\<\>:\<\>' + endfunction + + let b:match_words = 'JuliaGetMatchWords()' + + " we need to skip everything within comments, strings and + " the 'begin' and 'end' keywords when they are used as a range rather than as + " the delimiter of a block + let b:match_skip = 'synIDattr(synID(line("."),col("."),0),"name") =~# ' + \ . '"\\<julia\\%(Comprehension\\%(For\\|If\\)\\|RangeKeyword\\|Comment\\%([LM]\\|Delim\\)\\|\\%([bs]\\|Shell\\|Printf\\|Doc\\)\\?String\\|StringPrefixed\\|DocStringM\\(Raw\\)\\?\\|RegEx\\|SymbolS\\?\\|Dotted\\)\\>"' + + let b:undo_ftplugin = b:undo_ftplugin + \ . " | unlet! b:match_words b:match_skip b:match_ignorecase" + \ . " | unlet! b:julia_begin_keywords b:julia_end_keywords" + \ . " | delfunction JuliaGetMatchWords" + +endif + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/runtime/indent/julia.vim b/runtime/indent/julia.vim new file mode 100644 index 0000000000..a90cff49e4 --- /dev/null +++ b/runtime/indent/julia.vim @@ -0,0 +1,491 @@ +" Vim indent file +" Language: Julia +" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com> +" Homepage: https://github.com/JuliaEditorSupport/julia-vim +" Last Change: 2016 jun 16 +" Notes: originally based on Bram Molenaar's indent file for vim + +setlocal autoindent + +setlocal indentexpr=GetJuliaIndent() +setlocal indentkeys+==end,=else,=catch,=finally,),],} +setlocal indentkeys-=0# +setlocal indentkeys-=: +setlocal indentkeys-=0{ +setlocal indentkeys-=0} +setlocal nosmartindent + +" Only define the function once. +if exists("*GetJuliaIndent") + finish +endif + +let s:skipPatternsBasic = '\<julia\%(Comment\%([LM]\|Delim\)\)\>' +let s:skipPatterns = '\<julia\%(Comprehension\%(For\|If\)\|RangeKeyword\|Comment\%([LM]\|Delim\)\|\%([bs]\|Shell\|Printf\|Doc\)\?String\|StringPrefixed\|DocStringM\(Raw\)\?\|RegEx\|SymbolS\?\|Macro\|Dotted\)\>' + +function JuliaMatch(lnum, str, regex, st, ...) + let s = a:st + let e = a:0 > 0 ? a:1 : -1 + let basic_skip = a:0 > 1 ? a:2 : 'all' + let skip = basic_skip ==# 'basic' ? s:skipPatternsBasic : s:skipPatterns + while 1 + let f = match(a:str, '\C' . a:regex, s) + if e >= 0 && f >= e + return -1 + endif + if f >= 0 + let attr = synIDattr(synID(a:lnum,f+1,1),"name") + let attrT = synIDattr(synID(a:lnum,f+1,0),"name") + if attr =~# skip || attrT =~# skip + let s = f+1 + continue + endif + endif + break + endwhile + return f +endfunction + +function GetJuliaNestingStruct(lnum, ...) + " Auxiliary function to inspect the block structure of a line + let line = getline(a:lnum) + let s = a:0 > 0 ? a:1 : 0 + let e = a:0 > 1 ? a:2 : -1 + let blocks_stack = [] + let num_closed_blocks = 0 + while 1 + let fb = JuliaMatch(a:lnum, line, '\<\%(if\|else\%(if\)\?\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e) + let fe = JuliaMatch(a:lnum, line, '\<end\>', s, e) + + if fb < 0 && fe < 0 + " No blocks found + break + end + + if fb >= 0 && (fb < fe || fe < 0) + " The first occurrence is an opening block keyword + " Note: some keywords (elseif,else,catch,finally) are both + " closing blocks and opening new ones + + let i = JuliaMatch(a:lnum, line, '\<if\>', s) + if i >= 0 && i == fb + let s = i+1 + call add(blocks_stack, 'if') + continue + endif + let i = JuliaMatch(a:lnum, line, '\<elseif\>', s) + if i >= 0 && i == fb + let s = i+1 + if len(blocks_stack) > 0 && blocks_stack[-1] == 'if' + let blocks_stack[-1] = 'elseif' + elseif (len(blocks_stack) > 0 && blocks_stack[-1] != 'elseif') || len(blocks_stack) == 0 + call add(blocks_stack, 'elseif') + let num_closed_blocks += 1 + endif + continue + endif + let i = JuliaMatch(a:lnum, line, '\<else\>', s) + if i >= 0 && i == fb + let s = i+1 + if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>' + let blocks_stack[-1] = 'else' + else + call add(blocks_stack, 'else') + let num_closed_blocks += 1 + endif + continue + endif + + let i = JuliaMatch(a:lnum, line, '\<try\>', s) + if i >= 0 && i == fb + let s = i+1 + call add(blocks_stack, 'try') + continue + endif + let i = JuliaMatch(a:lnum, line, '\<catch\>', s) + if i >= 0 && i == fb + let s = i+1 + if len(blocks_stack) > 0 && blocks_stack[-1] == 'try' + let blocks_stack[-1] = 'catch' + else + call add(blocks_stack, 'catch') + let num_closed_blocks += 1 + endif + continue + endif + let i = JuliaMatch(a:lnum, line, '\<finally\>', s) + if i >= 0 && i == fb + let s = i+1 + if len(blocks_stack) > 0 && (blocks_stack[-1] == 'try' || blocks_stack[-1] == 'catch') + let blocks_stack[-1] = 'finally' + else + call add(blocks_stack, 'finally') + let num_closed_blocks += 1 + endif + continue + endif + + let i = JuliaMatch(a:lnum, line, '\<\%(bare\)\?module\>', s) + if i >= 0 && i == fb + let s = i+1 + if i == 0 + call add(blocks_stack, 'col1module') + else + call add(blocks_stack, 'other') + endif + continue + endif + + let i = JuliaMatch(a:lnum, line, '\<\%(while\|for\|function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\|let\|quote\|do\)\>', s) + if i >= 0 && i == fb + if match(line, '\C\<\%(mutable\|abstract\|primitive\)', i) != -1 + let s = i+11 + else + let s = i+1 + endif + call add(blocks_stack, 'other') + continue + endif + + " Note: it should be impossible to get here + break + + else + " The first occurrence is an 'end' + + let s = fe+1 + if len(blocks_stack) == 0 + let num_closed_blocks += 1 + else + call remove(blocks_stack, -1) + endif + continue + + endif + + " Note: it should be impossible to get here + break + endwhile + let num_open_blocks = len(blocks_stack) - count(blocks_stack, 'col1module') + return [num_open_blocks, num_closed_blocks] +endfunction + +function GetJuliaNestingBrackets(lnum, c) + " Auxiliary function to inspect the brackets structure of a line + let line = getline(a:lnum)[0 : (a:c - 1)] + let s = 0 + let brackets_stack = [] + let last_closed_bracket = -1 + while 1 + let fb = JuliaMatch(a:lnum, line, '[([{]', s) + let fe = JuliaMatch(a:lnum, line, '[])}]', s) + + if fb < 0 && fe < 0 + " No brackets found + break + end + + if fb >= 0 && (fb < fe || fe < 0) + " The first occurrence is an opening bracket + + let i = JuliaMatch(a:lnum, line, '(', s) + if i >= 0 && i == fb + let s = i+1 + call add(brackets_stack, ['par',i]) + continue + endif + + let i = JuliaMatch(a:lnum, line, '\[', s) + if i >= 0 && i == fb + let s = i+1 + call add(brackets_stack, ['sqbra',i]) + continue + endif + + let i = JuliaMatch(a:lnum, line, '{', s) + if i >= 0 && i == fb + let s = i+1 + call add(brackets_stack, ['curbra',i]) + continue + endif + + " Note: it should be impossible to get here + break + + else + " The first occurrence is a closing bracket + + let i = JuliaMatch(a:lnum, line, ')', s) + if i >= 0 && i == fe + let s = i+1 + if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'par' + call remove(brackets_stack, -1) + else + let last_closed_bracket = i + 1 + endif + continue + endif + + let i = JuliaMatch(a:lnum, line, ']', s) + if i >= 0 && i == fe + let s = i+1 + if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'sqbra' + call remove(brackets_stack, -1) + else + let last_closed_bracket = i + 1 + endif + continue + endif + + let i = JuliaMatch(a:lnum, line, '}', s) + if i >= 0 && i == fe + let s = i+1 + if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'curbra' + call remove(brackets_stack, -1) + else + let last_closed_bracket = i + 1 + endif + continue + endif + + " Note: it should be impossible to get here + break + + endif + + " Note: it should be impossible to get here + break + endwhile + let first_open_bracket = -1 + let last_open_bracket = -1 + let infuncargs = 0 + if len(brackets_stack) > 0 + let first_open_bracket = brackets_stack[0][1] + let last_open_bracket = brackets_stack[-1][1] + if brackets_stack[-1][0] == 'par' && IsFunctionArgPar(a:lnum, last_open_bracket+1) + let infuncargs = 1 + endif + endif + return [first_open_bracket, last_open_bracket, last_closed_bracket, infuncargs] +endfunction + +let s:bracketBlocks = '\<julia\%(\%(\%(Printf\)\?Par\|SqBra\%(Idx\)\?\|CurBra\)Block\|ParBlockInRange\|StringVars\%(Par\|SqBra\|CurBra\)\|Dollar\%(Par\|SqBra\)\|QuotedParBlockS\?\)\>' + +function IsInBrackets(lnum, c) + let stack = map(synstack(a:lnum, a:c), 'synIDattr(v:val, "name")') + call filter(stack, 'v:val =~# s:bracketBlocks') + return len(stack) > 0 +endfunction + +function IsInDocString(lnum) + let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")') + call filter(stack, 'v:val =~# "\\<juliaDocString\\(Delim\\|M\\\(Raw\\)\\?\\)\\?\\>"') + return len(stack) > 0 +endfunction + +function IsInContinuationImportLine(lnum) + let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")') + call filter(stack, 'v:val =~# "\\<juliaImportLine\\>"') + if len(stack) == 0 + return 0 + endif + return JuliaMatch(a:lnum, getline(a:lnum), '\<\%(import\|using\|export\)\>', indent(a:lnum)) == -1 +endfunction + +function IsFunctionArgPar(lnum, c) + if a:c == 0 + return 0 + endif + let stack = map(synstack(a:lnum, a:c-1), 'synIDattr(v:val, "name")') + return len(stack) >= 2 && stack[-2] ==# 'juliaFunctionDef' +endfunction + +function JumpToMatch(lnum, last_closed_bracket) + " we use the % command to skip back (tries to ues matchit if possible, + " otherwise resorts to vim's default, which is buggy but better than + " nothing) + call cursor(a:lnum, a:last_closed_bracket) + let percmap = maparg("%", "n") + if exists("g:loaded_matchit") && percmap =~# 'Match\%(it\|_wrapper\)' + normal % + else + normal! % + end +endfunction + +" Auxiliary function to find a line which does not start in the middle of a +" multiline bracketed expression, to be used as reference for block +" indentation. +function LastBlockIndent(lnum) + let lnum = a:lnum + let ind = 0 + while lnum > 0 + let ind = indent(lnum) + if ind == 0 + return [lnum, 0] + endif + if !IsInBrackets(lnum, 1) + break + endif + let lnum = prevnonblank(lnum - 1) + endwhile + return [max([lnum,1]), ind] +endfunction + +function GetJuliaIndent() + " Do not alter doctrings indentation + if IsInDocString(v:lnum) + return -1 + endif + + " Find a non-blank line above the current line. + let lnum = prevnonblank(v:lnum - 1) + + " At the start of the file use zero indent. + if lnum == 0 + return 0 + endif + + let ind = -1 + let st = -1 + let lim = -1 + + " Multiline bracketed expressions take precedence + let align_brackets = get(g:, "julia_indent_align_brackets", 1) + let align_funcargs = get(g:, "julia_indent_align_funcargs", 0) + let c = len(getline(lnum)) + 1 + while IsInBrackets(lnum, c) + let [first_open_bracket, last_open_bracket, last_closed_bracket, infuncargs] = GetJuliaNestingBrackets(lnum, c) + + " First scenario: the previous line has a hanging open bracket: + " set the indentation to match the opening bracket (plus an extra space) + " unless we're in a function arguments list or alignment is disabled, in + " which case we just add an extra indent + if last_open_bracket != -1 + if (!infuncargs && align_brackets) || (infuncargs && align_funcargs) + let st = last_open_bracket + let ind = virtcol([lnum, st + 1]) + else + let ind = indent(lnum) + shiftwidth() + endif + + " Second scenario: some multiline bracketed expression was closed in the + " previous line. But since we know we are still in a bracketed expression, + " we need to find the line where the bracket was opened + elseif last_closed_bracket != -1 + call JumpToMatch(lnum, last_closed_bracket) + if line(".") == lnum + " something wrong here, give up + let ind = indent(lnum) + else + let lnum = line(".") + let c = col(".") - 1 + if c == 0 + " uhm, give up + let ind = 0 + else + " we skipped a bracket set, keep searching for an opening bracket + let lim = c + continue + endif + endif + + " Third scenario: nothing special: keep the indentation + else + let ind = indent(lnum) + endif + + " Does the current line start with a closing bracket? Then depending on + " the situation we align it with the opening one, or we let the rest of + " the code figure it out (the case in which we're closing a function + " argument list is special-cased) + if JuliaMatch(v:lnum, getline(v:lnum), '[])}]', indent(v:lnum)) == indent(v:lnum) && ind > 0 + if !align_brackets && !align_funcargs + call JumpToMatch(v:lnum, indent(v:lnum)) + return indent(line(".")) + elseif (align_brackets && getline(v:lnum)[indent(v:lnum)] != ')') || align_funcargs + return ind - 1 + else " must be a ')' and align_brackets==1 and align_funcargs==0 + call JumpToMatch(v:lnum, indent(v:lnum)) + if IsFunctionArgPar(line("."), col(".")) + let ind = -1 + else + return ind - 1 + endif + endif + endif + + break + endwhile + + if ind == -1 + " We are not in a multiline bracketed expression. Thus we look for a + " previous line to use as a reference + let [lnum,ind] = LastBlockIndent(lnum) + let c = len(getline(lnum)) + 1 + if IsInBrackets(lnum, c) + let [first_open_bracket, last_open_bracket, last_closed_bracket, infuncargs] = GetJuliaNestingBrackets(lnum, c) + let lim = first_open_bracket + endif + end + + " Analyse the reference line + let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum, st, lim) + " Increase indentation for each newly opened block in the reference line + let ind += shiftwidth() * num_open_blocks + + " Analyse the current line + let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum) + " Decrease indentation for each closed block in the current line + let ind -= shiftwidth() * num_closed_blocks + + " Additional special case: multiline import/using/export statements + + let prevline = getline(lnum) + " Are we in a multiline import/using/export statement, right below the + " opening line? + if IsInContinuationImportLine(v:lnum) && !IsInContinuationImportLine(lnum) + if get(g:, 'julia_indent_align_import', 1) + " if the opening line has a colon followed by non-comments, use it as + " reference point + let cind = JuliaMatch(lnum, prevline, ':', indent(lnum), lim) + if cind >= 0 + let nonwhiteind = JuliaMatch(lnum, prevline, '\S', cind+1, -1, 'basic') + if nonwhiteind >= 0 + " return match(prevline, '\S', cind+1) " a bit overkill... + return cind + 2 + endif + else + " if the opening line is not a naked import/using/export statement, use + " it as reference + let iind = JuliaMatch(lnum, prevline, '\<import\|using\|export\>', indent(lnum), lim) + if iind >= 0 + " assuming whitespace after using... so no `using(XYZ)` please! + let nonwhiteind = JuliaMatch(lnum, prevline, '\S', iind+6, -1, 'basic') + if nonwhiteind >= 0 + return match(prevline, '\S', iind+6) + endif + endif + endif + endif + let ind += shiftwidth() + + " Or did we just close a multiline import/using/export statement? + elseif !IsInContinuationImportLine(v:lnum) && IsInContinuationImportLine(lnum) + " find the starting line of the statement + let ilnum = 0 + for iln in range(lnum-1, 1, -1) + if !IsInContinuationImportLine(iln) + let ilnum = iln + break + endif + endfor + if ilnum == 0 + " something went horribly wrong, give up + let ind = indent(lnum) + endif + let ind = indent(ilnum) + endif + + return ind +endfunction diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 87ecc3eeea..ca8db73d43 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -218,7 +218,7 @@ local function validate_client_config(config) config = { config, 't' }; } validate { - root_dir = { config.root_dir, is_dir, "directory" }; + root_dir = { config.root_dir, optional_validator(is_dir), "directory" }; handlers = { config.handlers, "t", true }; capabilities = { config.capabilities, "t", true }; cmd_cwd = { config.cmd_cwd, optional_validator(is_dir), "directory" }; @@ -289,6 +289,7 @@ end local changetracking = {} do + --@private --- client_id → state --- --- state @@ -547,7 +548,7 @@ end --- --- The following parameters describe fields in the {config} table. --- ---@param root_dir: (required, string) Directory where the LSP server will base +--@param root_dir: (string) Directory where the LSP server will base --- its rootUri on initialization. --- --@param cmd: (required, string or list treated like |jobstart()|) Base command @@ -772,7 +773,7 @@ function lsp.start_client(config) } local version = vim.version() - if not config.workspace_folders then + if config.root_dir and not config.workspace_folders then config.workspace_folders = {{ uri = vim.uri_from_fname(config.root_dir); name = string.format("%s", config.root_dir); @@ -797,7 +798,7 @@ function lsp.start_client(config) rootPath = config.root_dir; -- The rootUri of the workspace. Is null if no folder is open. If both -- `rootPath` and `rootUri` are set `rootUri` wins. - rootUri = vim.uri_from_fname(config.root_dir); + rootUri = config.root_dir and vim.uri_from_fname(config.root_dir); -- User provided initialization options. initializationOptions = config.init_options; -- The capabilities provided by the client (editor or tool) diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 5efd8d74a7..a244e3d6a4 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -362,11 +362,12 @@ end ---@param bufnr number ---@param client_id number|nil If nil, then return all of the diagnostics. --- Else, return just the diagnostics associated with the client_id. -function M.get(bufnr, client_id) +---@param predicate function|nil Optional function for filtering diagnostics +function M.get(bufnr, client_id, predicate) if client_id == nil then local all_diagnostics = {} for iter_client_id, _ in pairs(diagnostic_cache[bufnr]) do - local iter_diagnostics = M.get(bufnr, iter_client_id) + local iter_diagnostics = M.get(bufnr, iter_client_id, predicate) for _, diagnostic in ipairs(iter_diagnostics) do table.insert(all_diagnostics, diagnostic) @@ -376,19 +377,26 @@ function M.get(bufnr, client_id) return all_diagnostics end - return diagnostic_cache[bufnr][client_id] or {} + predicate = predicate or function(_) return true end + local client_diagnostics = {} + for _, diagnostic in ipairs(diagnostic_cache[bufnr][client_id] or {}) do + if predicate(diagnostic) then + table.insert(client_diagnostics, diagnostic) + end + end + return client_diagnostics end --- Get the diagnostics by line --- ----@param bufnr number The buffer number ----@param line_nr number The line number +---@param bufnr number|nil The buffer number +---@param line_nr number|nil The line number ---@param opts table|nil Configuration keys --- - severity: (DiagnosticSeverity, default nil) --- - Only return diagnostics with this severity. Overrides severity_limit --- - severity_limit: (DiagnosticSeverity, default nil) --- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid. ----@param client_id number the client id +---@param client_id|nil number the client id ---@return table Table with map of line number to list of diagnostics. -- Structured: { [1] = {...}, [5] = {.... } } function M.get_line_diagnostics(bufnr, line_nr, opts, client_id) @@ -464,63 +472,64 @@ end -- }}} -- Diagnostic Movements {{{ ---- Helper function to iterate through all of the diagnostic lines ----@return table list of diagnostics -local _iter_diagnostic_lines = function(start, finish, step, bufnr, opts, client_id) - if bufnr == nil then - bufnr = vim.api.nvim_get_current_buf() - end - +--- Helper function to find the next diagnostic relative to a position +---@return table the next diagnostic if found +local _next_diagnostic = function(position, search_forward, bufnr, opts, client_id) + position[1] = position[1] - 1 + bufnr = bufnr or vim.api.nvim_get_current_buf() local wrap = if_nil(opts.wrap, true) - - local search = function(search_start, search_finish, search_step) - for line_nr = search_start, search_finish, search_step do - local line_diagnostics = M.get_line_diagnostics(bufnr, line_nr, opts, client_id) - if line_diagnostics and not vim.tbl_isempty(line_diagnostics) then - return line_diagnostics + local line_count = vim.api.nvim_buf_line_count(bufnr) + for i = 0, line_count do + local offset = i * (search_forward and 1 or -1) + local line_nr = position[1] + offset + if line_nr < 0 or line_nr >= line_count then + if not wrap then + return end + line_nr = (line_nr + line_count) % line_count end - end - - local result = search(start, finish, step) - - if wrap then - local wrap_start, wrap_finish - if step == 1 then - wrap_start, wrap_finish = 1, start - else - wrap_start, wrap_finish = vim.api.nvim_buf_line_count(bufnr), start - end - - if not result then - result = search(wrap_start, wrap_finish, step) + local line_diagnostics = M.get_line_diagnostics(bufnr, line_nr, opts, client_id) + if line_diagnostics and not vim.tbl_isempty(line_diagnostics) then + local sort_diagnostics, is_next + if search_forward then + sort_diagnostics = function(a, b) return a.range.start.character < b.range.start.character end + is_next = function(diagnostic) return diagnostic.range.start.character > position[2] end + else + sort_diagnostics = function(a, b) return a.range.start.character > b.range.start.character end + is_next = function(diagnostic) return diagnostic.range.start.character < position[2] end + end + table.sort(line_diagnostics, sort_diagnostics) + if i == 0 then + for _, v in pairs(line_diagnostics) do + if is_next(v) then + return v + end + end + else + return line_diagnostics[1] + end end end - - return result end --@private ---- Helper function to ierate through diagnostic lines and return a position +--- Helper function to return a position from a diagnostic --- ---@return table {row, col} -local function _iter_diagnostic_lines_pos(opts, line_diagnostics) +local function _diagnostic_pos(opts, diagnostic) opts = opts or {} local win_id = opts.win_id or vim.api.nvim_get_current_win() local bufnr = vim.api.nvim_win_get_buf(win_id) - if line_diagnostics == nil or vim.tbl_isempty(line_diagnostics) then - return false - end + if not diagnostic then return false end - local iter_diagnostic = line_diagnostics[1] - return to_position(iter_diagnostic.range.start, bufnr) + return to_position(diagnostic.range.start, bufnr) end --@private -- Move to the diagnostic position -local function _iter_diagnostic_move_pos(name, opts, pos) +local function _diagnostic_move_pos(name, opts, pos) opts = opts or {} local enable_popup = if_nil(opts.enable_popup, true) @@ -536,7 +545,7 @@ local function _iter_diagnostic_move_pos(name, opts, pos) if enable_popup then -- This is a bit weird... I'm surprised that we need to wait til the next tick to do this. vim.schedule(function() - M.show_line_diagnostics(opts.popup_opts, vim.api.nvim_win_get_buf(win_id)) + M.show_position_diagnostics(opts.popup_opts, vim.api.nvim_win_get_buf(win_id)) end) end end @@ -552,14 +561,14 @@ function M.get_prev(opts) local bufnr = vim.api.nvim_win_get_buf(win_id) local cursor_position = opts.cursor_position or vim.api.nvim_win_get_cursor(win_id) - return _iter_diagnostic_lines(cursor_position[1] - 2, 0, -1, bufnr, opts, opts.client_id) + return _next_diagnostic(cursor_position, false, bufnr, opts, opts.client_id) end --- Return the pos, {row, col}, for the prev diagnostic in the current buffer. ---@param opts table See |vim.lsp.diagnostic.goto_next()| ---@return table Previous diagnostic position function M.get_prev_pos(opts) - return _iter_diagnostic_lines_pos( + return _diagnostic_pos( opts, M.get_prev(opts) ) @@ -568,7 +577,7 @@ end --- Move to the previous diagnostic ---@param opts table See |vim.lsp.diagnostic.goto_next()| function M.goto_prev(opts) - return _iter_diagnostic_move_pos( + return _diagnostic_move_pos( "DiagnosticPrevious", opts, M.get_prev_pos(opts) @@ -585,14 +594,14 @@ function M.get_next(opts) local bufnr = vim.api.nvim_win_get_buf(win_id) local cursor_position = opts.cursor_position or vim.api.nvim_win_get_cursor(win_id) - return _iter_diagnostic_lines(cursor_position[1], vim.api.nvim_buf_line_count(bufnr), 1, bufnr, opts, opts.client_id) + return _next_diagnostic(cursor_position, true, bufnr, opts, opts.client_id) end --- Return the pos, {row, col}, for the next diagnostic in the current buffer. ---@param opts table See |vim.lsp.diagnostic.goto_next()| ---@return table Next diagnostic position function M.get_next_pos(opts) - return _iter_diagnostic_lines_pos( + return _diagnostic_pos( opts, M.get_next(opts) ) @@ -617,7 +626,7 @@ end --- - {win_id}: (number, default 0) --- - Window ID function M.goto_next(opts) - return _iter_diagnostic_move_pos( + return _diagnostic_move_pos( "DiagnosticNext", opts, M.get_next_pos(opts) @@ -1208,7 +1217,7 @@ end -- }}} -- Diagnostic User Functions {{{ ---- Open a floating window with the diagnostics from {line_nr} +--- Open a floating window with the provided diagnostics --- --- The floating window can be customized with the following highlight groups: --- <pre> @@ -1218,32 +1227,21 @@ end --- LspDiagnosticsFloatingHint --- </pre> ---@param opts table Configuration table ---- - show_header (boolean, default true): Show "Diagnostics:" header. ---- - Plus all the opts for |vim.lsp.diagnostic.get_line_diagnostics()| ---- and |vim.lsp.util.open_floating_preview()| can be used here. ----@param bufnr number The buffer number ----@param line_nr number The line number ----@param client_id number|nil the client id +--- - show_header (boolean, default true): Show "Diagnostics:" header +--- - all opts for |vim.lsp.util.open_floating_preview()| can be used here +---@param diagnostics table: The diagnostics to display ---@return table {popup_bufnr, win_id} -function M.show_line_diagnostics(opts, bufnr, line_nr, client_id) - opts = opts or {} - - local show_header = if_nil(opts.show_header, true) - - bufnr = bufnr or 0 - line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) - +local function show_diagnostics(opts, diagnostics) + if vim.tbl_isempty(diagnostics) then return end local lines = {} local highlights = {} + local show_header = if_nil(opts.show_header, true) if show_header then table.insert(lines, "Diagnostics:") table.insert(highlights, {0, "Bold"}) end - local line_diagnostics = M.get_line_diagnostics(bufnr, line_nr, opts, client_id) - if vim.tbl_isempty(line_diagnostics) then return end - - for i, diagnostic in ipairs(line_diagnostics) do + for i, diagnostic in ipairs(diagnostics) do local prefix = string.format("%d. ", i) local hiname = M._get_floating_severity_highlight_name(diagnostic.severity) assert(hiname, 'unknown severity: ' .. tostring(diagnostic.severity)) @@ -1257,7 +1255,6 @@ function M.show_line_diagnostics(opts, bufnr, line_nr, client_id) end end - opts.focus_id = "line_diagnostics" local popup_bufnr, winnr = util.open_floating_preview(lines, 'plaintext', opts) for i, hi in ipairs(highlights) do local prefixlen, hiname = unpack(hi) @@ -1268,6 +1265,57 @@ function M.show_line_diagnostics(opts, bufnr, line_nr, client_id) return popup_bufnr, winnr end +--- Open a floating window with the diagnostics from {position} + +---@param opts table|nil Configuration keys +--- - severity: (DiagnosticSeverity, default nil) +--- - Only return diagnostics with this severity. Overrides severity_limit +--- - severity_limit: (DiagnosticSeverity, default nil) +--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid. +--- - all opts for |show_diagnostics()| can be used here +---@param buf_nr number|nil The buffer number +---@param position table|nil The (0,0)-indexed position +---@return table {popup_bufnr, win_id} +function M.show_position_diagnostics(opts, buf_nr, position) + opts = opts or {} + opts.focus_id = "position_diagnostics" + buf_nr = buf_nr or vim.api.nvim_get_current_buf() + if not position then + local curr_position = vim.api.nvim_win_get_cursor(0) + curr_position[1] = curr_position[1] - 1 + position = curr_position + end + local match_position_predicate = function(diag) + return position[1] == diag.range['start'].line and + position[2] >= diag.range['start'].character and + (position[2] <= diag.range['end'].character or position[1] < diag.range['end'].line) + end + local position_diagnostics = M.get(buf_nr, nil, match_position_predicate) + if opts.severity then + position_diagnostics = filter_to_severity_limit(opts.severity, position_diagnostics) + elseif opts.severity_limit then + position_diagnostics = filter_by_severity_limit(opts.severity_limit, position_diagnostics) + end + table.sort(position_diagnostics, function(a, b) return a.severity < b.severity end) + return show_diagnostics(opts, position_diagnostics) +end + +--- Open a floating window with the diagnostics from {line_nr} + +---@param opts table Configuration table +--- - all opts for |vim.lsp.diagnostic.get_line_diagnostics()| and +--- |show_diagnostics()| can be used here +---@param buf_nr number|nil The buffer number +---@param line_nr number|nil The line number +---@param client_id number|nil the client id +---@return table {popup_bufnr, win_id} +function M.show_line_diagnostics(opts, buf_nr, line_nr, client_id) + opts = opts or {} + opts.focus_id = "line_diagnostics" + line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) + local line_diagnostics = M.get_line_diagnostics(buf_nr, line_nr, opts, client_id) + return show_diagnostics(opts, line_diagnostics) +end --- Clear diagnotics and diagnostic cache --- diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index e003cf577a..bf5bd791c3 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -85,8 +85,10 @@ function TSHighlighterQuery.new(lang, query_string) hl = _link_default_highlight_once(lang .. hl, hl) end - rawset(table, capture, hl) - return hl + local id = a.nvim_get_hl_id_by_name(hl) + + rawset(table, capture, id) + return id end }) diff --git a/runtime/syntax/julia.vim b/runtime/syntax/julia.vim new file mode 100644 index 0000000000..2c2d36a97a --- /dev/null +++ b/runtime/syntax/julia.vim @@ -0,0 +1,550 @@ +" Vim syntax file +" Language: julia +" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com> +" Homepage: https://github.com/JuliaEditorSupport/julia-vim +" Last Change: 2013 feb 11 + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +if version < 704 + " this is used to disable regex syntax like `\@3<=' + " on older vim versions + function! s:d(x) + return '' + endfunction +else + function! s:d(x) + return string(a:x) + endfunction +endif + +scriptencoding utf-8 + +let s:julia_spellcheck_strings = get(g:, "julia_spellcheck_strings", 0) +let s:julia_spellcheck_docstrings = get(g:, "julia_spellcheck_docstrings", 1) +let s:julia_spellcheck_comments = get(g:, "julia_spellcheck_comments", 1) + +let s:julia_highlight_operators = get(g:, "julia_highlight_operators", 1) + +" List of characters, up to \UFF, which cannot be used in identifiers. +" (It includes operator characters; we don't consider them identifiers.) +" This is used mostly in lookbehinds with `\@<=`, e.g. when we need to check +" that that we're not in the middle of an identifier. +" It doesn't include a few characters (spaces and all closing parentheses) +" because those may or may not be valid in the lookbehind on a case-by-case +" basis. +let s:nonid_chars = '\U00-\U08' . '\U0A-\U1F' + \ . '\U21-\U28' . '\U2A-\U2F' . '\U3A-\U40' . '\U5B-\U5E' . '\U60' . '\U7B\U7C' + \ . '\U7E-\UA1' . '\UA7\UA8' . '\UAB-\UAD' . '\UAF\UB1\UB4' . '\UB6-\UB8' . '\UBB\UBF' . '\UD7\UF7' + +" The complete list +let s:nonidS_chars = '[:space:])\U5D}' . s:nonid_chars + + +" List of all valid operator chars up to \UFF (NOTE: they must all be included +" in s:nonidS_chars, so that if we include that, then this is redundant) +" It does not include '!' since it can be used in an identifier. +" The list contains the following characters: '%&*+-/<=>\\^|~¬±×÷' +let s:op_chars = '\U25\U26\U2A\U2B\U2D\U2F\U3C-\U3E\U5C\U5E\U7C\U7E\UAC\UB1\UD7\UF7' + +" List of all valid operator chars above \UFF +" Written with ranges for performance reasons +" The list contains the following characters: '…⁝⅋←↑→↓↔↚↛↜↝↞↠↢↣↤↦↩↪↫↬↮↶↷↺↻↼↽⇀⇁⇄⇆⇇⇉⇋⇌⇍⇎⇏⇐⇒⇔⇚⇛⇜⇝⇠⇢⇴⇵⇶⇷⇸⇹⇺⇻⇼⇽⇾⇿∈∉∊∋∌∍∓∔∗∘∙√∛∜∝∤∥∦∧∨∩∪∷∸∺∻∽∾≀≁≂≃≄≅≆≇≈≉≊≋≌≍≎≏≐≑≒≓≔≕≖≗≘≙≚≛≜≝≞≟≠≡≢≣≤≥≦≧≨≩≪≫≬≭≮≯≰≱≲≳≴≵≶≷≸≹≺≻≼≽≾≿⊀⊁⊂⊃⊄⊅⊆⊇⊈⊉⊊⊋⊍⊎⊏⊐⊑⊒⊓⊔⊕⊖⊗⊘⊙⊚⊛⊜⊞⊟⊠⊡⊢⊣⊩⊬⊮⊰⊱⊲⊳⊴⊵⊶⊷⊻⊼⊽⋄⋅⋆⋇⋉⋊⋋⋌⋍⋎⋏⋐⋑⋒⋓⋕⋖⋗⋘⋙⋚⋛⋜⋝⋞⋟⋠⋡⋢⋣⋤⋥⋦⋧⋨⋩⋪⋫⋬⋭⋮⋯⋰⋱⋲⋳⋴⋵⋶⋷⋸⋹⋺⋻⋼⋽⋾⋿⌿▷⟂⟈⟉⟑⟒⟕⟖⟗⟰⟱⟵⟶⟷⟹⟺⟻⟼⟽⟾⟿⤀⤁⤂⤃⤄⤅⤆⤇⤈⤉⤊⤋⤌⤍⤎⤏⤐⤑⤒⤓⤔⤕⤖⤗⤘⤝⤞⤟⤠⥄⥅⥆⥇⥈⥉⥊⥋⥌⥍⥎⥏⥐⥑⥒⥓⥔⥕⥖⥗⥘⥙⥚⥛⥜⥝⥞⥟⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬⥭⥮⥯⥰⦷⦸⦼⦾⦿⧀⧁⧡⧣⧤⧥⧴⧶⧷⧺⧻⨇⨈⨝⨟⨢⨣⨤⨥⨦⨧⨨⨩⨪⨫⨬⨭⨮⨰⨱⨲⨳⨴⨵⨶⨷⨸⨹⨺⨻⨼⨽⩀⩁⩂⩃⩄⩅⩊⩋⩌⩍⩎⩏⩐⩑⩒⩓⩔⩕⩖⩗⩘⩚⩛⩜⩝⩞⩟⩠⩡⩢⩣⩦⩧⩪⩫⩬⩭⩮⩯⩰⩱⩲⩳⩴⩵⩶⩷⩸⩹⩺⩻⩼⩽⩾⩿⪀⪁⪂⪃⪄⪅⪆⪇⪈⪉⪊⪋⪌⪍⪎⪏⪐⪑⪒⪓⪔⪕⪖⪗⪘⪙⪚⪛⪜⪝⪞⪟⪠⪡⪢⪣⪤⪥⪦⪧⪨⪩⪪⪫⪬⪭⪮⪯⪰⪱⪲⪳⪴⪵⪶⪷⪸⪹⪺⪻⪼⪽⪾⪿⫀⫁⫂⫃⫄⫅⫆⫇⫈⫉⫊⫋⫌⫍⫎⫏⫐⫑⫒⫓⫔⫕⫖⫗⫘⫙⫛⫷⫸⫹⫺⬰⬱⬲⬳⬴⬵⬶⬷⬸⬹⬺⬻⬼⬽⬾⬿⭀⭁⭂⭃⭄⭇⭈⭉⭊⭋⭌←↑→↓' +let s:op_chars_wc = '\U2026\U205D\U214B\U2190-\U2194\U219A-\U219E\U21A0\U21A2-\U21A4\U21A6\U21A9-\U21AC\U21AE\U21B6\U21B7\U21BA-\U21BD\U21C0\U21C1\U21C4\U21C6\U21C7\U21C9\U21CB-\U21D0\U21D2\U21D4\U21DA-\U21DD\U21E0\U21E2\U21F4-\U21FF\U2208-\U220D\U2213\U2214\U2217-\U221D\U2224-\U222A\U2237\U2238\U223A\U223B\U223D\U223E\U2240-\U228B\U228D-\U229C\U229E-\U22A3\U22A9\U22AC\U22AE\U22B0-\U22B7\U22BB-\U22BD\U22C4-\U22C7\U22C9-\U22D3\U22D5-\U22FF\U233F\U25B7\U27C2\U27C8\U27C9\U27D1\U27D2\U27D5-\U27D7\U27F0\U27F1\U27F5-\U27F7\U27F9-\U27FF\U2900-\U2918\U291D-\U2920\U2944-\U2970\U29B7\U29B8\U29BC\U29BE-\U29C1\U29E1\U29E3-\U29E5\U29F4\U29F6\U29F7\U29FA\U29FB\U2A07\U2A08\U2A1D\U2A1F\U2A22-\U2A2E\U2A30-\U2A3D\U2A40-\U2A45\U2A4A-\U2A58\U2A5A-\U2A63\U2A66\U2A67\U2A6A-\U2AD9\U2ADB\U2AF7-\U2AFA\U2B30-\U2B44\U2B47-\U2B4C\UFFE9-\UFFEC' + +" Full operators regex +let s:operators = '\%(' . '\.\%([-+*/^÷%|&⊻]\|//\|\\\|>>\|>>>\?\)\?=' . + \ '\|' . '[:<>]=\|||\|&&\||>\|<|\|[<>:]:\|<<\|>>>\?\|//\|[-=]>\|\.\.\.\?' . + \ '\|' . '\.\?[!' . s:op_chars . s:op_chars_wc . ']' . + \ '\)' + + +" Characters that can be used to start an identifier. Above \UBF we don't +" bother checking. (If a UTF8 operator is used, it will take precedence anyway.) +let s:id_charsH = '\%([A-Za-z_\UA2-\UA6\UA9\UAA\UAE\UB0\UB5\UBA]\|[^\U00-\UBF]\)' +" Characters that can appear in an identifier, starting in 2nd position. Above +" \UBF we check for operators since we need to stop the identifier if one +" appears. We don't check for invalid characters though. +let s:id_charsW = '\%([0-9A-Za-z_!\UA2-\UA6\UA9\UAA\UAE-\UB0\UB2-\UB5\UB8-\UBA\UBC-\UBE]\|[^\U00-\UBF]\@=[^' . s:op_chars_wc . ']\)' + +" A valid julia identifier, more or less +let s:idregex = '\%(' . s:id_charsH . s:id_charsW . '*\)' + + + +syn case match + +syntax cluster juliaExpressions contains=@juliaParItems,@juliaStringItems,@juliaKeywordItems,@juliaBlocksItems,@juliaTypesItems,@juliaConstItems,@juliaMacroItems,@juliaSymbolItems,@juliaOperatorItems,@juliaNumberItems,@juliaCommentItems,@juliaErrorItems,@juliaSyntaxRegions +syntax cluster juliaExprsPrintf contains=@juliaExpressions,@juliaPrintfItems +syntax cluster juliaExprsNodot contains=@juliaParItems,@juliaStringItems,@juliaMacroItems,@juliaSymbolItems,@juliaOperatorItems,@juliaCommentItems,juliaIdSymbol + +syntax cluster juliaParItems contains=juliaParBlock,juliaSqBraIdxBlock,juliaSqBraBlock,juliaCurBraBlock,juliaQuotedParBlock,juliaQuotedQMarkPar +syntax cluster juliaKeywordItems contains=juliaKeyword,juliaWhereKeyword,juliaImportLine,juliaInfixKeyword,juliaRepKeyword +syntax cluster juliaBlocksItems contains=juliaConditionalBlock,juliaWhileBlock,juliaForBlock,juliaBeginBlock,juliaFunctionBlock,juliaMacroBlock,juliaQuoteBlock,juliaTypeBlock,juliaImmutableBlock,juliaExceptionBlock,juliaLetBlock,juliaDoBlock,juliaModuleBlock,juliaStructBlock,juliaMutableStructBlock,juliaAbstractBlock,juliaPrimitiveBlock +syntax cluster juliaTypesItems contains=juliaBaseTypeBasic,juliaBaseTypeNum,juliaBaseTypeC,juliaBaseTypeError,juliaBaseTypeIter,juliaBaseTypeString,juliaBaseTypeArray,juliaBaseTypeDict,juliaBaseTypeSet,juliaBaseTypeIO,juliaBaseTypeProcess,juliaBaseTypeRange,juliaBaseTypeRegex,juliaBaseTypeFact,juliaBaseTypeFact,juliaBaseTypeSort,juliaBaseTypeRound,juliaBaseTypeSpecial,juliaBaseTypeRandom,juliaBaseTypeDisplay,juliaBaseTypeTime,juliaBaseTypeOther + +syntax cluster juliaConstItems contains=juliaConstNum,juliaConstBool,juliaConstEnv,juliaConstMMap,juliaConstC,juliaConstGeneric,juliaConstIO,juliaPossibleEuler + +syntax cluster juliaMacroItems contains=juliaPossibleMacro,juliaDollarVar,juliaDollarPar,juliaDollarSqBra +syntax cluster juliaSymbolItems contains=juliaPossibleSymbol +syntax cluster juliaNumberItems contains=juliaNumbers +syntax cluster juliaStringItems contains=juliaChar,juliaString,juliabString,juliasString,juliaShellString,juliaDocString,juliaRegEx +syntax cluster juliaPrintfItems contains=juliaPrintfParBlock,juliaPrintfString +syntax cluster juliaOperatorItems contains=juliaOperator,juliaRangeOperator,juliaCTransOperator,juliaTernaryRegion,juliaColon,juliaSemicolon,juliaComma +syntax cluster juliaCommentItems contains=juliaCommentL,juliaCommentM +syntax cluster juliaErrorItems contains=juliaErrorPar,juliaErrorEnd,juliaErrorElse,juliaErrorCatch,juliaErrorFinally + +syntax cluster juliaSyntaxRegions contains=juliaIdSymbol,juliaTypeOperatorR2,juliaTypeOperatorR3,juliaWhereR,juliaDotted + +syntax cluster juliaSpellcheckStrings contains=@spell +syntax cluster juliaSpellcheckDocStrings contains=@spell +syntax cluster juliaSpellcheckComments contains=@spell + +if !s:julia_spellcheck_docstrings + syntax cluster juliaSpellcheckDocStrings remove=@spell +endif +if !s:julia_spellcheck_strings + syntax cluster juliaSpellcheckStrings remove=@spell +endif +if !s:julia_spellcheck_comments + syntax cluster juliaSpellcheckComments remove=@spell +endif + +syntax match juliaSemicolon display ";" +syntax match juliaComma display "," +syntax match juliaColon display ":" + +" A dot can introduce a sort of 'environment' such that words after it are not +" recognized as keywords. This has low precedence so that it can be overridden +" by operators +syntax match juliaDotted transparent "\.\s*[^])}.]" contains=@juliaExprsNodot +syntax match juliaDottedT contained transparent "\.\s*[^])}.]" contains=@juliaExprsNodot,juliaType + +syntax match juliaErrorPar display "[])}]" +syntax match juliaErrorEnd display "\<end\>" +syntax match juliaErrorElse display "\<\%(else\|elseif\)\>" +syntax match juliaErrorCatch display "\<catch\>" +syntax match juliaErrorFinally display "\<finally\>" +syntax match juliaErrorSemicol display contained ";" + +syntax region juliaParBlock matchgroup=juliaParDelim start="(" end=")" contains=@juliaExpressions,juliaComprehensionFor +syntax region juliaParBlockInRange matchgroup=juliaParDelim contained start="(" end=")" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeKeyword,juliaComprehensionFor +syntax region juliaSqBraIdxBlock matchgroup=juliaParDelim start="\[" end="\]" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeKeyword,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS +exec 'syntax region juliaSqBraBlock matchgroup=juliaParDelim start="\%(^\|\s\|' . s:operators . '\)\@'.s:d(3).'<=\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS' +syntax region juliaCurBraBlock matchgroup=juliaParDelim start="{" end="}" contains=juliaType,juliaDottedT,@juliaExpressions + +exec 'syntax match juliaType contained "\%(' . s:idregex . '\.\)*\zs' . s:idregex . '"' + +" This is a generic identifier followed by some symbol, either a type +" operator (<: or >:), or an open parenthesis, or an open curly bracket. +" It's used to recognize one of the contained regions looking for identifiers +" only once. Once recognized, those regions no longer need to use the +" expensive s:idregex. +exec 'syntax match juliaIdSymbol transparent "' . s:idregex . '\%(\s*[<>]:\|\.\?(\|{\|\"\)\@=" contains=juliaFunctionCall,juliaParamType,juliaStringPrefixed,juliaTypeOperatorR1' + +syntax match juliaFunctionCall contained "[^{([:space:]<>\"]\+(\@=" nextgroup=juliaParBlock + +exec 'syntax match juliaFunctionDef contained transparent "\%(\<\%(function\|macro\)\)\@'.s:d(8).'<=\s\+\zs' . s:idregex . '\%(\.' . s:idregex . '\)*\ze\s*\%((\|\send\>\|$\)" contains=juliaFunctionName' +exec 'syntax match juliaFunctionName contained "\%(\<\%(function\|macro\)\s\+\)\@'.s:d(20).'<=\%(' . s:idregex . '\.\)*\zs' . s:idregex . '"' + +exec 'syntax match juliaStructR contained transparent "\%(\<\%(\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\)\s\+\)\@'.s:d(20).'<=\%(' . s:idregex . '\.\)*' . s:idregex . '\>\(\s*(\)\@!" contains=juliaType' + +syntax match juliaKeyword display "\<\%(return\|local\|global\|const\)\>" +syntax match juliaInfixKeyword display "\%(=\s*\)\@<!\<\%(in\|isa\)\>\S\@!\%(\s*=\)\@!" + +" The import/export/using keywords introduce a sort of special parsing +" environment with its own rules +exec 'syntax region juliaImportLine matchgroup=juliaKeyword excludenl start="\<\%(import\|using\|export\)\>" skip="\%(\%(\<\%(import\|using\|export\)\>\)\|^\)\@'.s:d(6).'<=$" end="$" end="\%([])}]\)\@=" contains=@juliaExpressions,juliaAsKeyword,@juliaContinuationItems,juliaMacroName' +syntax match juliaAsKeyword display contained "\<as\>" + +syntax match juliaRepKeyword display "\<\%(break\|continue\)\>" +syntax region juliaConditionalBlock matchgroup=juliaConditional start="\<if\>" end="\<end\>" contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock fold +syntax region juliaConditionalEIBlock matchgroup=juliaConditional transparent contained start="\<elseif\>" end="\<\%(end\|else\|elseif\)\>"me=s-1 contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock +syntax region juliaConditionalEBlock matchgroup=juliaConditional transparent contained start="\<else\>" end="\<end\>"me=s-1 contains=@juliaExpressions +syntax region juliaWhileBlock matchgroup=juliaRepeat start="\<while\>" end="\<end\>" contains=@juliaExpressions fold +syntax region juliaForBlock matchgroup=juliaRepeat start="\<for\>" end="\<end\>" contains=@juliaExpressions,juliaOuter fold +syntax region juliaBeginBlock matchgroup=juliaBlKeyword start="\<begin\>" end="\<end\>" contains=@juliaExpressions fold +syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start="\<function\>" end="\<end\>" contains=@juliaExpressions,juliaFunctionDef fold +syntax region juliaMacroBlock matchgroup=juliaBlKeyword start="\<macro\>" end="\<end\>" contains=@juliaExpressions,juliaFunctionDef fold +syntax region juliaQuoteBlock matchgroup=juliaBlKeyword start="\<quote\>" end="\<end\>" contains=@juliaExpressions fold +syntax region juliaStructBlock matchgroup=juliaBlKeyword start="\<struct\>" end="\<end\>" contains=@juliaExpressions,juliaStructR fold +syntax region juliaMutableStructBlock matchgroup=juliaBlKeyword start="\<mutable\s\+struct\>" end="\<end\>" contains=@juliaExpressions,juliaStructR fold +syntax region juliaLetBlock matchgroup=juliaBlKeyword start="\<let\>" end="\<end\>" contains=@juliaExpressions fold +syntax region juliaDoBlock matchgroup=juliaBlKeyword start="\<do\>" end="\<end\>" contains=@juliaExpressions fold +syntax region juliaModuleBlock matchgroup=juliaBlKeyword start="\<\%(bare\)\?module\>" end="\<end\>" contains=@juliaExpressions fold +syntax region juliaExceptionBlock matchgroup=juliaException start="\<try\>" end="\<end\>" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold +syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="\<catch\>" end="\<end\>"me=s-1 contains=@juliaExpressions,juliaFinallyBlock +syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="\<finally\>" end="\<end\>"me=s-1 contains=@juliaExpressions +syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="\<abstract\s\+type\>" end="\<end\>" fold contains=@juliaExpressions,juliaStructR +syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="\<primitive\s\+type\>" end="\<end\>" fold contains=@juliaExpressions,juliaStructR + +exec 'syntax region juliaComprehensionFor matchgroup=juliaComprehensionFor transparent contained start="\%([^[:space:],;:({[]\_s*\)\@'.s:d(80).'<=\<for\>" end="\ze[]);]" contains=@juliaExpressions,juliaComprehensionIf,juliaComprehensionFor' +syntax match juliaComprehensionIf contained "\<if\>" + +exec 'syntax match juliaOuter contained "\<outer\ze\s\+' . s:idregex . '\>"' + +syntax match juliaRangeKeyword contained "\<\%(begin\|end\)\>" + +syntax match juliaBaseTypeBasic display "\<\%(\%(N\|Named\)\?Tuple\|Symbol\|Function\|Union\%(All\)\?\|Type\%(Name\|Var\)\?\|Any\|ANY\|Vararg\|Ptr\|Exception\|Module\|Expr\|DataType\|\%(LineNumber\|Quote\)Node\|\%(Weak\|Global\)\?Ref\|Method\|Pair\|Val\|Nothing\|Some\|Missing\)\>" +syntax match juliaBaseTypeNum display "\<\%(U\?Int\%(8\|16\|32\|64\|128\)\?\|Float\%(16\|32\|64\)\|Complex\|Bool\|Char\|Number\|Signed\|Unsigned\|Integer\|AbstractFloat\|Real\|Rational\|\%(Abstract\)\?Irrational\|Enum\|BigInt\|BigFloat\|MathConst\|ComplexF\%(16\|32\|64\)\)\>" +syntax match juliaBaseTypeC display "\<\%(FileOffset\|C\%(u\?\%(char\|short\|int\|long\(long\)\?\|w\?string\)\|float\|double\|\%(ptrdiff\|s\?size\|wchar\|off\|u\?intmax\)_t\|void\)\)\>" +syntax match juliaBaseTypeError display "\<\%(\%(Bounds\|Divide\|Domain\|\%(Stack\)\?Overflow\|EOF\|Undef\%(Ref\|Var\)\|System\|Type\|Parse\|Argument\|Key\|Load\|Method\|Inexact\|OutOfMemory\|Init\|Assertion\|ReadOnlyMemory\|StringIndex\)Error\|\%(Interrupt\|Error\|ProcessExited\|Captured\|Composite\|InvalidState\|Missing\|\%(Process\|Task\)Failed\)Exception\|DimensionMismatch\|SegmentationFault\)\>" +syntax match juliaBaseTypeIter display "\<\%(EachLine\|Enumerate\|Cartesian\%(Index\|Range\)\|LinSpace\|CartesianIndices\)\>" +syntax match juliaBaseTypeString display "\<\%(DirectIndex\|Sub\|Rep\|Rev\|Abstract\|Substitution\)\?String\>" +syntax match juliaBaseTypeArray display "\<\%(\%(Sub\)\?Array\|\%(Abstract\|Dense\|Strided\)\?\%(Array\|Matrix\|Vec\%(tor\|OrMat\)\)\|SparseMatrixCSC\|\%(AbstractSparse\|Bit\|Shared\)\%(Array\|Vector\|Matrix\)\|\%\(D\|Bid\|\%(Sym\)\?Trid\)iagonal\|Hermitian\|Symmetric\|UniformScaling\|\%(Lower\|Upper\)Triangular\|\%(Sparse\|Row\)Vector\|VecElement\|Conj\%(Array\|Matrix\|Vector\)\|Index\%(Cartesian\|Linear\|Style\)\|PermutedDimsArray\|Broadcasted\|Adjoint\|Transpose\|LinearIndices\)\>" +syntax match juliaBaseTypeDict display "\<\%(WeakKey\|Id\|Abstract\)\?Dict\>" +syntax match juliaBaseTypeSet display "\<\%(\%(Abstract\|Bit\)\?Set\)\>" +syntax match juliaBaseTypeIO display "\<\%(IO\%(Stream\|Buffer\|Context\)\?\|RawFD\|StatStruct\|FileMonitor\|PollingFileWatcher\|Timer\|Base64\%(Decode\|Encode\)Pipe\|\%(UDP\|TCP\)Socket\|\%(Abstract\)\?Channel\|BufferStream\|ReentrantLock\|GenericIOBuffer\)\>" +syntax match juliaBaseTypeProcess display "\<\%(Pipe\|Cmd\|PipeBuffer\)\>" +syntax match juliaBaseTypeRange display "\<\%(Dims\|RangeIndex\|\%(Abstract\|Lin\|Ordinal\|Step\|\%(Abstract\)\?Unit\)Range\|Colon\|ExponentialBackOff\|StepRangeLen\)\>" +syntax match juliaBaseTypeRegex display "\<Regex\%(Match\)\?\>" +syntax match juliaBaseTypeFact display "\<\%(Factorization\|BunchKaufman\|\%(Cholesky\|QR\)\%(Pivoted\)\?\|\%(Generalized\)\?\%(Eigen\|SVD\|Schur\)\|Hessenberg\|LDLt\|LQ\|LU\)\>" +syntax match juliaBaseTypeSort display "\<\%(Insertion\|\(Partial\)\?Quick\|Merge\)Sort\>" +syntax match juliaBaseTypeRound display "\<Round\%(ingMode\|FromZero\|Down\|Nearest\%(Ties\%(Away\|Up\)\)\?\|ToZero\|Up\)\>" +syntax match juliaBaseTypeSpecial display "\<\%(LocalProcess\|ClusterManager\)\>" +syntax match juliaBaseTypeRandom display "\<\%(AbstractRNG\|MersenneTwister\|RandomDevice\)\>" +syntax match juliaBaseTypeDisplay display "\<\%(Text\(Display\)\?\|\%(Abstract\)\?Display\|MIME\|HTML\)\>" +syntax match juliaBaseTypeTime display "\<\%(Date\%(Time\)\?\|DateFormat\)\>" +syntax match juliaBaseTypeOther display "\<\%(RemoteRef\|Task\|Condition\|VersionNumber\|IPv[46]\|SerializationState\|WorkerConfig\|Future\|RemoteChannel\|IPAddr\|Stack\%(Trace\|Frame\)\|\(Caching\|Worker\)Pool\|AbstractSerializer\)\>" + +syntax match juliaConstNum display "\%(\<\%(\%(NaN\|Inf\)\%(16\|32\|64\)\?\|pi\|π\)\>\)" +" Note: recognition of ℯ, which Vim does not consider a valid identifier, is +" complicated. We detect possible uses by just looking for the character (for +" performance) and then check that it's actually used by its own. +" (This also tries to detect preceding number constants; it does so in a crude +" way.) +syntax match juliaPossibleEuler "ℯ" contains=juliaEuler +exec 'syntax match juliaEuler contained "\%(\%(^\|[' . s:nonidS_chars . s:op_chars_wc . ']\)\%(.\?[0-9][.0-9eEf_]*\d\)\?\)\@'.s:d(80).'<=ℯ\ze[' . s:nonidS_chars . s:op_chars_wc . ']"' +syntax match juliaConstBool display "\<\%(true\|false\)\>" +syntax match juliaConstEnv display "\<\%(ARGS\|ENV\|ENDIAN_BOM\|LOAD_PATH\|VERSION\|PROGRAM_FILE\|DEPOT_PATH\)\>" +syntax match juliaConstIO display "\<\%(std\%(out\|in\|err\)\|devnull\)\>" +syntax match juliaConstC display "\<\%(C_NULL\)\>" +syntax match juliaConstGeneric display "\<\%(nothing\|Main\|undef\|missing\)\>" + +syntax match juliaParamType contained "[^{([:space:]<>\"]\+\ze{" nextgroup=juliaCurBraBlock + +syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro,juliaDocMacro,juliaDocMacroPre + +exec 'syntax match juliaMacro contained "@' . s:idregex . '\%(\.' . s:idregex . '\)*"' +syntax match juliaMacro contained "@[!.~$%^*/\\|<>+-]\ze[^0-9]" +exec 'syntax region juliaMacroCall contained transparent start="\(@' . s:idregex . '\%(\.' . s:idregex . '\)*\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS' +exec 'syntax region juliaMacroCall contained transparent start="\(@.\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS' +exec 'syntax region juliaMacroCallP contained transparent start="@' . s:idregex . '\%(\.' . s:idregex . '\)*(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock' +exec 'syntax region juliaMacroCallP contained transparent start="@.(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock' + +exec 'syntax match juliaNumbers transparent "\%(^\|[' . s:nonidS_chars . s:op_chars_wc . ']\)\@'.s:d(1).'<=\d\|\.\d\|im\>" contains=juliaNumber,juliaFloat,juliaComplexUnit' + +"integer regexes +let s:dec_regex = '\d\%(_\?\d\)*\%(\>\|im\>\|\ze\D\)' +let s:hex_regex = '0x\x\%(_\?\x\)*\%(\>\|im\>\|\ze\X\)' +let s:bin_regex = '0b[01]\%(_\?[01]\)*\%(\>\|im\>\|\ze[^01]\)' +let s:oct_regex = '0o\o\%(_\?\o\)*\%(\>\|im\>\|\ze\O\)' + +let s:int_regex = '\%(' . s:hex_regex . + \ '\|' . s:bin_regex . + \ '\|' . s:oct_regex . + \ '\|' . s:dec_regex . + \ '\)' + +"floating point regexes +" starting with a dot, optional exponent +let s:float_regex1 = '\.\d\%(_\?\d\)*\%([eEf][-+]\?\d\+\)\?\%(\>\|im\>\|\ze\D\)' +" with dot, optional exponent +let s:float_regex2 = '\d\%(_\?\d\)*\.\%(\d\%(_\?\d\)*\)\?\%([eEf][-+]\?\d\+\)\?\%(\>\|im\>\|\ze\D\)' +" without dot, with exponent +let s:float_regex3 = '\d\%(_\?\d\)*[eEf][-+]\?\d\+\%(\>\|im\>\|\ze\D\)' + +"hex floating point numbers +" starting with a dot +let s:hexfloat_regex1 = '0x\.\%\(\x\%(_\?\x\)*\)\?[pP][-+]\?\d\+\%(\>\|im\>\|\ze\X\)' +" starting with a digit +let s:hexfloat_regex2 = '0x\x\%(_\?\x\)*\%\(\.\%\(\x\%(_\?\x\)*\)\?\)\?[pP][-+]\?\d\+\%(\>\|im\>\|\ze\X\)' + +let s:float_regex = '\%(' . s:float_regex3 . + \ '\|' . s:float_regex2 . + \ '\|' . s:float_regex1 . + \ '\|' . s:hexfloat_regex2 . + \ '\|' . s:hexfloat_regex1 . + \ '\)' + +exec 'syntax match juliaNumber contained "' . s:int_regex . '" contains=juliaComplexUnit' +exec 'syntax match juliaFloat contained "' . s:float_regex . '" contains=juliaComplexUnit' +syntax match juliaComplexUnit display contained "\<im\>" + +syntax match juliaRangeOperator display ":" +exec 'syntax match juliaOperator "' . s:operators . '"' + +exec 'syntax region juliaTernaryRegion matchgroup=juliaTernaryOperator start="\s\zs?\ze\s" skip="\%(:\(:\|[^:[:space:]'."'".'"({[]\+\s*\ze:\)\|\%(?\s*\)\@'.s:d(6).'<=:(\)" end=":" contains=@juliaExpressions,juliaErrorSemicol' + +let s:interp_dollar = '\([' . s:nonidS_chars . s:op_chars_wc . '!]\|^\)\@'.s:d(1).'<=\$' + +exec 'syntax match juliaDollarVar display contained "' . s:interp_dollar . s:idregex . '"' +exec 'syntax region juliaDollarPar matchgroup=juliaDollarVar contained start="' .s:interp_dollar . '(" end=")" contains=@juliaExpressions' +exec 'syntax region juliaDollarSqBra matchgroup=juliaDollarVar contained start="' .s:interp_dollar . '\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS' + +syntax match juliaChar "'\\\?.'" contains=juliaSpecialChar +syntax match juliaChar display "'\\\o\{3\}'" contains=juliaOctalEscapeChar +syntax match juliaChar display "'\\x\x\{2\}'" contains=juliaHexEscapeChar +syntax match juliaChar display "'\\u\x\{1,4\}'" contains=juliaUniCharSmall +syntax match juliaChar display "'\\U\x\{1,8\}'" contains=juliaUniCharLarge + +exec 'syntax match juliaCTransOperator "[[:space:]}' . s:nonid_chars . s:op_chars_wc . '!]\@'.s:d(1).'<!\.\?' . "'" . 'ᵀ\?"' + +" TODO: some of these might be specialized; the rest could be just left to the +" generic juliaStringPrefixed fallback +syntax region juliaString matchgroup=juliaStringDelim start=+\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaStringVars,@juliaSpecialChars,@juliaSpellcheckStrings +syntax region juliaStringPrefixed contained matchgroup=juliaStringDelim start=+[^{([:space:]<>"]\+\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpecialCharsRaw +syntax region juliabString matchgroup=juliaStringDelim start=+\<b\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpecialChars +syntax region juliasString matchgroup=juliaStringDelim start=+\<s\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpecialChars + +syntax region juliaDocString matchgroup=juliaDocStringDelim fold start=+^"""+ skip=+\%(\\\\\)*\\"+ end=+"""+ contains=@juliaStringVars,@juliaSpecialChars,@juliaSpellcheckDocStrings + +exec 'syntax region juliaPrintfMacro contained transparent start="@s\?printf(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaPrintfParBlock' +syntax region juliaPrintfMacro contained transparent start="@s\?printf\s\+" end="\ze\%([])};#]\|$\|\<for\>\)" contains=@juliaExprsPrintf,juliaMacro,juliaSymbolS,juliaQuotedParBlockS +syntax region juliaPrintfParBlock contained matchgroup=juliaParDelim start="(" end=")" contains=@juliaExprsPrintf +syntax region juliaPrintfString contained matchgroup=juliaStringDelim start=+"+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=@juliaSpecialChars,@juliaPrintfChars + +exec 'syntax region juliaDocMacroPre contained transparent start=+@doc\s\+\%(' . s:idregex . '\%(\.' . s:idregex . '\)*\)\z("\%(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\(\z1\)\@'.s:d(3).'<=+ contains=juliaMacro,juliaDocStringMRaw' +exec 'syntax region juliaDocMacro contained transparent start=+@doc\s\+\z("\%(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\(\z1\)\@'.s:d(3).'<=+ contains=juliaMacro,juliaDocStringM' +syntax region juliaDocStringMRaw contained fold matchgroup=juliaDocStringDelim fold start=+\z\("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpellcheckDocStrings +syntax region juliaDocStringM contained fold matchgroup=juliaDocStringDelim fold start=+\z\("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaStringVars,@juliaSpecialChars,@juliaSpellcheckDocStrings + +syntax region juliaShellString matchgroup=juliaStringDelim start=+`+ skip=+\%(\\\\\)*\\`+ end=+`+ contains=@juliaStringVars,juliaSpecialChar + +syntax cluster juliaStringVars contains=juliaStringVarsPar,juliaStringVarsSqBra,juliaStringVarsCurBra,juliaStringVarsPla +syntax region juliaStringVarsPar contained matchgroup=juliaStringVarDelim start="$(" end=")" contains=@juliaExpressions +syntax region juliaStringVarsSqBra contained matchgroup=juliaStringVarDelim start="$\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS +syntax region juliaStringVarsCurBra contained matchgroup=juliaStringVarDelim start="${" end="}" contains=@juliaExpressions +exec 'syntax match juliaStringVarsPla contained "\$' . s:idregex . '"' + +" TODO improve RegEx +syntax region juliaRegEx matchgroup=juliaStringDelim start=+\<r\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1[imsx]*+ + +syntax cluster juliaSpecialChars contains=juliaSpecialChar,juliaDoubleBackslash,juliaEscapedQuote,juliaOctalEscapeChar,juliaHexEscapeChar,juliaUniCharSmall,juliaUniCharLarge +syntax match juliaSpecialChar display contained "\\." +syntax match juliaOctalEscapeChar display contained "\\\o\{3\}" +syntax match juliaHexEscapeChar display contained "\\x\x\{2\}" +syntax match juliaUniCharSmall display contained "\\u\x\{1,4\}" +syntax match juliaUniCharLarge display contained "\\U\x\{1,8\}" +syntax cluster juliaSpecialCharsRaw contains=juliaDoubleBackslash,juliaEscapedQuote +syntax match juliaDoubleBackslash contained "\\\\" +syntax match juliaEscapedQuote contained "\\\"" + +syntax cluster juliaPrintfChars contains=juliaErrorPrintfFmt,juliaPrintfFmt +syntax match juliaErrorPrintfFmt display contained "\\\?%." +syntax match juliaPrintfFmt display contained "%\%(\d\+\$\)\=[-+' #0]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjqzt]\|ll\|hh\)\=[aAbdiuoxXDOUfFeEgGcCsSpn]" +syntax match juliaPrintfFmt display contained "%%" +syntax match juliaPrintfFmt display contained "\\%\%(\d\+\$\)\=[-+' #0]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjqzt]\|ll\|hh\)\=[aAbdiuoxXDOUfFeEgGcCsSpn]"hs=s+1 +syntax match juliaPrintfFmt display contained "\\%%"hs=s+1 + +" this is used to restrict the search for Symbols to when colons appear at all +" (for performance reasons) +syntax match juliaPossibleSymbol transparent ":\ze[^:]" contains=juliaSymbol,juliaQuotedParBlock,juliaQuotedQMarkPar,juliaColon + +let s:quotable = '\%(' . s:idregex . '\|' . s:operators . '\|[?.]\|' . s:float_regex . '\|' . s:int_regex . '\)' +let s:quoting_colon = '\%(\%(^\s*\|\s\{6,\}\|[' . s:nonid_chars . s:op_chars_wc . ']\s*\)\@'.s:d(6).'<=\|\%(\<\%(return\|if\|else\%(if\)\?\|while\|try\|begin\)\s\+\)\@'.s:d(9).'<=\)\zs:' +let s:quoting_colonS = '\s\@'.s:d(1).'<=:' + +" note: juliaSymbolS only works within whitespace-sensitive contexts, +" such as in macro calls without parentheses, or within square brackets. +" It is used to override the recognition of expressions like `a :b` as +" ranges rather than symbols in those contexts. +" (Note that such `a :b` expressions only allows at most 5 spaces between +" the identifier and the colon anyway.) + +exec 'syntax match juliaSymbol contained "' . s:quoting_colon . s:quotable . '"' +exec 'syntax match juliaSymbolS contained "' . s:quoting_colonS . s:quotable . '"' + +" same as above for quoted expressions such as :(expr) +exec 'syntax region juliaQuotedParBlock matchgroup=juliaQParDelim start="' . s:quoting_colon . '(" end=")" contains=@juliaExpressions' +exec 'syntax match juliaQuotedQMarkPar "' . s:quoting_colon . '(\s*?\s*)" contains=juliaQuotedQMark' +exec 'syntax region juliaQuotedParBlockS matchgroup=juliaQParDelim contained start="' . s:quoting_colonS . '(" end=")" contains=@juliaExpressions' + + +syntax match juliaTypeOperatorR1 contained "[^{([:space:]<>\"]\+\%(\s*[<>]:\)\@=" + +" force precedence over Symbols +syntax match juliaTypeOperator contained "[<>:]:" +exec 'syntax match juliaTypeOperatorR2 transparent "[<>:]:\s*\%(' . s:idregex . '\.\)*' . s:idregex . '" contains=juliaTypeOperator,juliaType,juliaDottedT,@juliaExpressions nextgroup=juliaTypeOperator' +syntax match juliaIsaKeyword contained "\<isa\>" +exec 'syntax match juliaTypeOperatorR3 transparent "\<isa\s\+\%(' . s:idregex . '\.\)*' . s:idregex . '" contains=juliaIsaKeyword,juliaType,juliaDottedT,@juliaExpressions nextgroup=juliaIsaKeyword' + +syntax match juliaWhereKeyword "\<where\>" +exec 'syntax match juliaWhereR transparent "\<where\s\+' . s:idregex . '" contains=juliaWhereKeyword,juliaType,juliaDottedT,juliaIdSymbol' + +syntax region juliaCommentL matchgroup=juliaCommentDelim excludenl start="#\ze\%([^=]\|$\)" end="$" contains=juliaTodo,@juliaSpellcheckComments +syntax region juliaCommentM matchgroup=juliaCommentDelim fold start="#=\ze\%([^#]\|$\)" end="=#" contains=juliaTodo,juliaCommentM,@juliaSpellcheckComments +syntax keyword juliaTodo contained TODO FIXME XXX + +" detect an end-of-line with only whitespace or comments before it +let s:eol = '\s*\%(\%(\%(#=\%(=#\@!\|[^=]\|\n\)\{-}=#\)\s*\)\+\)\?\%(#=\@!.*\)\?\n' + +" a trailing comma, or colon, or an empty line in an import/using/export +" multi-line command. Used to recognize the as keyword, and for indentation +" (this needs to take precedence over normal commas and colons, and comments) +syntax cluster juliaContinuationItems contains=juliaContinuationComma,juliaContinuationColon,juliaContinuationNone +exec 'syntax region juliaContinuationComma matchgroup=juliaComma contained start=",\ze'.s:eol.'" end="\n\+\ze." contains=@juliaCommentItems' +exec 'syntax region juliaContinuationColon matchgroup=juliaColon contained start=":\ze'.s:eol.'" end="\n\+\ze." contains=@juliaCommentItems' +exec 'syntax region juliaContinuationNone matchgroup=NONE contained start="\%(\<\%(import\|using\|export\)\>\|^\)\@'.s:d(6).'<=\ze'.s:eol.'" end="\n\+\ze." contains=@juliaCommentItems,juliaAsKeyword' +exec 'syntax match juliaMacroName contained "@' . s:idregex . '\%(\.' . s:idregex . '\)*"' + +" the following are disabled by default, but +" can be enabled by entering e.g. +" :hi link juliaParDelim Delimiter +hi def link juliaParDelim juliaNone +hi def link juliaSemicolon juliaNone +hi def link juliaComma juliaNone +hi def link juliaFunctionCall juliaNone + +hi def link juliaColon juliaOperator + +hi def link juliaFunctionName juliaFunction +hi def link juliaFunctionName1 juliaFunction +hi def link juliaMacroName juliaMacro + + +hi def link juliaKeyword Keyword +hi def link juliaWhereKeyword Keyword +hi def link juliaInfixKeyword Keyword +hi def link juliaIsaKeyword Keyword +hi def link juliaAsKeyword Keyword +hi def link juliaRepKeyword Keyword +hi def link juliaBlKeyword Keyword +hi def link juliaConditional Conditional +hi def link juliaRepeat Repeat +hi def link juliaException Exception +hi def link juliaOuter Keyword +hi def link juliaBaseTypeBasic Type +hi def link juliaBaseTypeNum Type +hi def link juliaBaseTypeC Type +hi def link juliaBaseTypeError Type +hi def link juliaBaseTypeIter Type +hi def link juliaBaseTypeString Type +hi def link juliaBaseTypeArray Type +hi def link juliaBaseTypeDict Type +hi def link juliaBaseTypeSet Type +hi def link juliaBaseTypeIO Type +hi def link juliaBaseTypeProcess Type +hi def link juliaBaseTypeRange Type +hi def link juliaBaseTypeRegex Type +hi def link juliaBaseTypeFact Type +hi def link juliaBaseTypeSort Type +hi def link juliaBaseTypeRound Type +hi def link juliaBaseTypeSpecial Type +hi def link juliaBaseTypeRandom Type +hi def link juliaBaseTypeDisplay Type +hi def link juliaBaseTypeTime Type +hi def link juliaBaseTypeOther Type + +hi def link juliaType Type +hi def link juliaParamType Type +hi def link juliaTypeOperatorR1 Type + +" NOTE: deprecated constants are not highlighted as such. For once, +" one can still legitimately use them by importing Base.MathConstants. +" Plus, one-letter variables like `e` and `γ` can be used with other +" meanings. +hi def link juliaConstNum Constant +hi def link juliaEuler Constant + +hi def link juliaConstEnv Constant +hi def link juliaConstC Constant +hi def link juliaConstLimits Constant +hi def link juliaConstGeneric Constant +hi def link juliaRangeKeyword Constant +hi def link juliaConstBool Boolean +hi def link juliaConstIO Boolean + +hi def link juliaComprehensionFor Keyword +hi def link juliaComprehensionIf Keyword + +hi def link juliaDollarVar Identifier + +hi def link juliaFunction Function +hi def link juliaMacro Macro +hi def link juliaSymbol Identifier +hi def link juliaSymbolS Identifier +hi def link juliaQParDelim Identifier +hi def link juliaQuotedQMarkPar Identifier +hi def link juliaQuotedQMark juliaOperatorHL + +hi def link juliaNumber Number +hi def link juliaFloat Float +hi def link juliaComplexUnit Constant + +hi def link juliaChar Character + +hi def link juliaString String +hi def link juliaStringPrefixed juliaString +hi def link juliabString juliaString +hi def link juliasString juliaString +hi def link juliavString juliaString +hi def link juliarString juliaString +hi def link juliaipString juliaString +hi def link juliabigString juliaString +hi def link juliaMIMEString juliaString +hi def link juliarawString juliaString +hi def link juliatestString juliaString +hi def link juliahtmlString juliaString +hi def link juliaint128String juliaString +hi def link juliaPrintfString juliaString +hi def link juliaShellString juliaString +hi def link juliaDocString juliaString +hi def link juliaDocStringM juliaDocString +hi def link juliaDocStringMRaw juliaDocString +hi def link juliaStringDelim juliaString +hi def link juliaDocStringDelim juliaDocString +hi def link juliaStringVarsPla Identifier +hi def link juliaStringVarDelim Identifier + +hi def link juliaRegEx String + +hi def link juliaSpecialChar SpecialChar +hi def link juliaOctalEscapeChar SpecialChar +hi def link juliaHexEscapeChar SpecialChar +hi def link juliaUniCharSmall SpecialChar +hi def link juliaUniCharLarge SpecialChar +hi def link juliaDoubleBackslash SpecialChar +hi def link juliaEscapedQuote SpecialChar + +hi def link juliaPrintfFmt SpecialChar + +if s:julia_highlight_operators + hi! def link juliaOperatorHL Operator +else + hi! def link juliaOperatorHL juliaNone +endif +hi def link juliaOperator juliaOperatorHL +hi def link juliaRangeOperator juliaOperatorHL +hi def link juliaCTransOperator juliaOperatorHL +hi def link juliaTernaryOperator juliaOperatorHL +hi def link juliaTypeOperator juliaOperatorHL + +hi def link juliaCommentL Comment +hi def link juliaCommentM Comment +hi def link juliaCommentDelim Comment +hi def link juliaTodo Todo + +hi def link juliaErrorPar juliaError +hi def link juliaErrorEnd juliaError +hi def link juliaErrorElse juliaError +hi def link juliaErrorCatch juliaError +hi def link juliaErrorFinally juliaError +hi def link juliaErrorSemicol juliaError +hi def link juliaErrorPrintfFmt juliaError + +hi def link juliaError Error + +syntax sync fromstart + +let b:current_syntax = "julia" + +let &cpo = s:cpo_save +unlet s:cpo_save |