diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2020-03-25 09:53:16 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2020-03-25 09:53:41 +0100 |
commit | 751a031926d7de08e5294e131efc1e32580fe48e (patch) | |
tree | 7e30e73a56e6009e29b4647e79649b5fd330aca0 | |
parent | e11d1ae04fb1b544bfb154a33de69bc0b17ed6d2 (diff) | |
download | configs-751a031926d7de08e5294e131efc1e32580fe48e.tar.gz configs-751a031926d7de08e5294e131efc1e32580fe48e.zip |
Vim: Javascript line width changed to 110 and added ANTLR syntax.
-rw-r--r-- | files/vim/ftplugin/antlr/antlr3.vim | 91 | ||||
-rw-r--r-- | files/vim/ftplugin/antlr/antlr4.vim | 76 | ||||
-rw-r--r-- | files/vim/ftplugin/javascript/javascript.vim | 6 |
3 files changed, 170 insertions, 3 deletions
diff --git a/files/vim/ftplugin/antlr/antlr3.vim b/files/vim/ftplugin/antlr/antlr3.vim new file mode 100644 index 0000000..10e24e5 --- /dev/null +++ b/files/vim/ftplugin/antlr/antlr3.vim @@ -0,0 +1,91 @@ +" vim: ts=8 +" Vim syntax file +" Language: ANTLRv3 +" Maintainer: Jörn Horstmann (updated by Davyd Madeley) +" Last Change: 2008-11-21 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn keyword antlrKeyword grammar lexer parser tree header members options fragment returns throws scope init + +syn match antlrCharacter '\\\(r\|n\|t\|f\|b\|"\|\'\|\\\|u\x\{4}\)' contained display + +syn match antlrToken "\<[A-Z_][a-zA-Z_0-9]\+\>" +syn match antlrRule "[a-z][a-zA-Z_0-9]\+" +syn match antlrScopeVariable '$\k\+::\k\+' + +syn match antlrOperator "[:;@.]" +syn match antlrOperator "[()]" +syn match antlrOperator "[?+*~|!]" +syn match antlrOperator "[->=^]" + +syn match antlrBrace "[{}]" +syn match antlrBrace "[\[\]]" +syn region antlrAction matchgroup=antlrBrace start="[{\[]" end="[}\]]" contains=antlrVariable,antlrLiteral,antlrComment +syn match antlrVariable contained "$[a-zA-Z][a-zA-Z_0-9]*" + +syn region antlrLiteral start=+'+ end=+'+ contains=antlrCharacter +syn region antlrLiteral start=+"+ end=+"+ contains=antlrCharacter + +syn region antlrComment start="/\*" end="\*/" +syn match antlrComment "//.*$" + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 + if version < 508 + let did_antlr_syntax_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink antlrLiteral String + hi def antlrVariable term=bold cterm=bold gui=bold + HiLink antlrBrace Operator + HiLink antlrCharacter Special + HiLink antlrComment Comment + HiLink antlrOperator Operator + HiLink antlrKeyword Keyword + HiLink antlrToken PreProc + HiLink antlrScopeVariable Identifier + HiLink antlrRule Type + + delcommand HiLink +endif + +" try to figure out the target language +let target_languages = [] +" can we figure out from the file name +let extensions = split(expand('%:t'), '\.') +if len(extensions) >= 3 + " great.. the target language was provided via file name + call add(target_languages, tolower(extensions[-2])) +else + " no multiple extensions... have to figure out from the content + let buffer = join(getline(1, line('$')), "\n") + let antlr_options = matchstr(buffer, '\m\(\_s\|;\)options\_s\+{\_.\{-\}}') + call substitute(antlr_options, '\mlanguage\_s*=\_s*''\?\(.\{-\}\)''\?\_s*;', '\=add(target_languages, tolower(submatch(1)))', 'g') +endif +if exists('target_languages[-1]') + " the last defined target language takes precendece + let lang=target_languages[-1] + let syntax_file = findfile('syntax/' . lang . '.vim', &rtp, 1) + if syntax_file != '' + " if a valid syntax file was found only + let b:current_syntax = '' + unlet b:current_syntax + let region_name = '@' . lang . 'Language' + exe 'syntax include ' . region_name . ' ' . syntax_file + exe 'syntax region ' . lang . ' start="{" end="}" keepend contains=' . region_name + endif +endif + +let b:current_syntax = "antlr3" diff --git a/files/vim/ftplugin/antlr/antlr4.vim b/files/vim/ftplugin/antlr/antlr4.vim new file mode 100644 index 0000000..456076c --- /dev/null +++ b/files/vim/ftplugin/antlr/antlr4.vim @@ -0,0 +1,76 @@ +" vim: ts=8 +" Vim syntax file +" Language: ANTLRv4 +" Maintainer: Jörn Horstmann (updated by Dylon Edwards) +" Last Change: 2015-12-15 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn keyword antlrKeyword import fragment lexer parser grammar returns locals throws catch finally mode options tokens header members init after channels mode protected public private + +syn keyword antlrReserved rule + +syn match antlrCharacter '\\\(r\|n\|t\|f\|b\|"\|\'\|\\\|u\x\{4}\)' contained display + +syn match antlrToken "\<[A-Z_][a-zA-Z_0-9]\+\>" +syn match antlrRule "[a-z][a-zA-Z_0-9]\+" +syn match antlrScopeVariable '$\k\+::\k\+' + +syn match antlrOperator "[:;@.]" +syn match antlrOperator "[()]" +syn match antlrOperator "[?+*~|!]" +syn match antlrOperator "[->=^]" + +syn match antlrBlock "[{}]" +syn region antlrAction matchgroup=antlrBlock start="{" end="}" contains=antlrVariable,antlrAction +syn match antlrVariable contained "$[a-zA-Z][a-zA-Z_0-9]*" + +syn include @JAVA syntax/java.vim +syn region ANTLR4EmbeddedJavaAction matchgroup=antlrBlock start="{" end="}" contains=@JAVA,antlrVariable containedin=antlrAction + +syn keyword antlrOperations pushMode popMode skip channel + +syn match antlrBrace "[\[\]]" +syn region antlrCharClass matchgroup=antlrBrace start="\[" end="\]" contains=antlrCharacter + +syn region antlrLiteral start=+'+ end=+'+ contains=antlrCharacter +syn region antlrLiteral start=+"+ end=+"+ contains=antlrCharacter + +syn region antlrComment start="/\*" end="\*/" +syn match antlrComment "//.*$" + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 + if version < 508 + let did_antlr_syntax_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink antlrReserved Error + HiLink antlrOperations Identifier + HiLink antlrLiteral String + hi def antlrVariable term=bold cterm=bold gui=bold + HiLink antlrBrace Operator + HiLink antlrBlock Operator + HiLink antlrCharacter Special + HiLink antlrComment Comment + HiLink antlrOperator Operator + HiLink antlrKeyword Keyword + HiLink antlrToken PreProc + HiLink antlrScopeVariable Identifier + HiLink antlrRule Type + + delcommand HiLink +endif + +let b:current_syntax = "antlr4" diff --git a/files/vim/ftplugin/javascript/javascript.vim b/files/vim/ftplugin/javascript/javascript.vim index 1ca602c..2040643 100644 --- a/files/vim/ftplugin/javascript/javascript.vim +++ b/files/vim/ftplugin/javascript/javascript.vim @@ -11,9 +11,9 @@ setlocal tabstop=4 shiftwidth=4 expandtab " Show existing tabs (they can be deleted with :retab) setlocal list -" Column marker: 80 characters -call matchadd('ColorColumn', '\%81v', 100) -setlocal textwidth=80 +" Column marker: 110 characters +call matchadd('ColorColumn', '\%111v', 100) +setlocal textwidth=110 " Mappings nnoremap <buffer> <leader>C :sp ~/.vim/ftplugin/javascript/javascript.vim<CR> |