Add LLVM support (#376)
This commit is contained in:
parent
58f9b8cd02
commit
65f090faef
@ -105,6 +105,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
|
||||
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin)
|
||||
- [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin)
|
||||
- [llvm](https://github.com/llvm/llvm-project) (syntax, indent, ftplugin)
|
||||
- [lua](https://github.com/tbastos/vim-lua) (syntax, indent)
|
||||
- [mako](https://github.com/sophacles/vim-bundle-mako) (syntax, indent, ftplugin)
|
||||
- [markdown](https://github.com/plasticboy/vim-markdown) (syntax, indent)
|
||||
|
1
build
1
build
@ -213,6 +213,7 @@ PACKS="
|
||||
less:groenewege/vim-less
|
||||
liquid:tpope/vim-liquid
|
||||
livescript:gkz/vim-ls
|
||||
llvm:llvm/llvm-project:_ALL:/llvm/utils/vim/
|
||||
lua:tbastos/vim-lua
|
||||
mako:sophacles/vim-bundle-mako
|
||||
markdown:plasticboy/vim-markdown:_SYNTAX
|
||||
|
@ -677,6 +677,27 @@ autocmd BufNewFile,BufRead *Slakefile set filetype=ls
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'llvm') == -1
|
||||
augroup filetypedetect
|
||||
" llvm, from llvm-lit.vim in llvm/llvm-project:_ALL:/llvm/utils/vim/
|
||||
au BufRead,BufNewFile lit.*cfg set filetype=python
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'llvm') == -1
|
||||
augroup filetypedetect
|
||||
" llvm, from llvm.vim in llvm/llvm-project:_ALL:/llvm/utils/vim/
|
||||
au BufRead,BufNewFile *.ll set filetype=llvm
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'llvm') == -1
|
||||
augroup filetypedetect
|
||||
" llvm, from tablegen.vim in llvm/llvm-project:_ALL:/llvm/utils/vim/
|
||||
au BufRead,BufNewFile *.td set filetype=tablegen
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'mako') == -1
|
||||
augroup filetypedetect
|
||||
" mako, from mako.vim in sophacles/vim-bundle-mako
|
||||
|
16
ftplugin/llvm.vim
Normal file
16
ftplugin/llvm.vim
Normal file
@ -0,0 +1,16 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'llvm') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim filetype plugin file
|
||||
" Language: LLVM Assembly
|
||||
" Maintainer: The LLVM team, http://llvm.org/
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal softtabstop=2 shiftwidth=2
|
||||
setlocal expandtab
|
||||
setlocal comments+=:;
|
16
ftplugin/tablegen.vim
Normal file
16
ftplugin/tablegen.vim
Normal file
@ -0,0 +1,16 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'llvm') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim filetype plugin file
|
||||
" Language: LLVM TableGen
|
||||
" Maintainer: The LLVM team, http://llvm.org/
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal matchpairs+=<:>
|
||||
setlocal softtabstop=2 shiftwidth=2
|
||||
setlocal expandtab
|
76
indent/llvm.vim
Normal file
76
indent/llvm.vim
Normal file
@ -0,0 +1,76 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'llvm') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim indent file
|
||||
" Language: llvm
|
||||
" Maintainer: The LLVM team, http://llvm.org/
|
||||
" What this indent plugin currently does:
|
||||
" - If no other rule matches copy indent from previous non-empty,
|
||||
" non-commented line
|
||||
" - On '}' align the same as the line containing the matching '{'
|
||||
" - If previous line ends with ':' increase indentation
|
||||
" - If the current line ends with ':' indent at the same level as the
|
||||
" enclosing '{'/'}' block
|
||||
" Stuff that would be nice to add:
|
||||
" - Continue comments on next line
|
||||
" - If there is an opening+unclosed parenthesis on previous line indent to that
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal shiftwidth=2 expandtab
|
||||
|
||||
setlocal indentkeys=0{,0},<:>,!^F,o,O,e
|
||||
setlocal indentexpr=GetLLVMIndent()
|
||||
|
||||
if exists("*GetLLVMIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! FindOpenBrace(lnum)
|
||||
call cursor(a:lnum, 1)
|
||||
return searchpair('{', '', '}', 'bW')
|
||||
endfun
|
||||
|
||||
function! GetLLVMIndent()
|
||||
" On '}' align the same as the line containing the matching '{'
|
||||
let thisline = getline(v:lnum)
|
||||
if thisline =~ '^\s*}'
|
||||
call cursor(v:lnum, 1)
|
||||
silent normal %
|
||||
let opening_lnum = line('.')
|
||||
if opening_lnum != v:lnum
|
||||
return indent(opening_lnum)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Indent labels the same as the current opening block
|
||||
if thisline =~ ':\s*$'
|
||||
let blockbegin = FindOpenBrace(v:lnum)
|
||||
if blockbegin > 0
|
||||
return indent(blockbegin)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Find a non-blank not-completely commented line above the current line.
|
||||
let prev_lnum = prevnonblank(v:lnum - 1)
|
||||
while prev_lnum > 0 && synIDattr(synID(prev_lnum, indent(prev_lnum)+1, 0), "name") =? "string\|comment"
|
||||
let prev_lnum = prevnonblank(prev_lnum-1)
|
||||
endwhile
|
||||
" Hit the start of the file, use zero indent.
|
||||
if prev_lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(prev_lnum)
|
||||
let prevline = getline(prev_lnum)
|
||||
|
||||
" Add a 'shiftwidth' after lines that start a block or labels
|
||||
if prevline =~ '{\s*$' || prevline =~ ':\s*$'
|
||||
let ind = ind + &shiftwidth
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
238
syntax/llvm.vim
Normal file
238
syntax/llvm.vim
Normal file
@ -0,0 +1,238 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'llvm') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim syntax file
|
||||
" Language: llvm
|
||||
" Maintainer: The LLVM team, http://llvm.org/
|
||||
" Version: $Revision$
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn case match
|
||||
|
||||
" Types.
|
||||
" Types also include struct, array, vector, etc. but these don't
|
||||
" benefit as much from having dedicated highlighting rules.
|
||||
syn keyword llvmType void half float double x86_fp80 fp128 ppc_fp128
|
||||
syn keyword llvmType label metadata x86_mmx
|
||||
syn keyword llvmType type label opaque token
|
||||
syn match llvmType /\<i\d\+\>/
|
||||
|
||||
" Instructions.
|
||||
" The true and false tokens can be used for comparison opcodes, but it's
|
||||
" much more common for these tokens to be used for boolean constants.
|
||||
syn keyword llvmStatement add addrspacecast alloca and arcp ashr atomicrmw
|
||||
syn keyword llvmStatement bitcast br catchpad catchswitch catchret call callbr
|
||||
syn keyword llvmStatement cleanuppad cleanupret cmpxchg eq exact extractelement
|
||||
syn keyword llvmStatement extractvalue fadd fast fcmp fdiv fence fmul fpext
|
||||
syn keyword llvmStatement fptosi fptoui fptrunc free frem fsub fneg getelementptr
|
||||
syn keyword llvmStatement icmp inbounds indirectbr insertelement insertvalue
|
||||
syn keyword llvmStatement inttoptr invoke landingpad load lshr malloc max min
|
||||
syn keyword llvmStatement mul nand ne ninf nnan nsw nsz nuw oeq oge ogt ole
|
||||
syn keyword llvmStatement olt one or ord phi ptrtoint resume ret sdiv select
|
||||
syn keyword llvmStatement sext sge sgt shl shufflevector sitofp sle slt srem
|
||||
syn keyword llvmStatement store sub switch trunc udiv ueq uge ugt uitofp ule ult
|
||||
syn keyword llvmStatement umax umin une uno unreachable unwind urem va_arg
|
||||
syn keyword llvmStatement xchg xor zext
|
||||
|
||||
" Keywords.
|
||||
syn keyword llvmKeyword
|
||||
\ acq_rel
|
||||
\ acquire
|
||||
\ addrspace
|
||||
\ alias
|
||||
\ align
|
||||
\ alignstack
|
||||
\ alwaysinline
|
||||
\ appending
|
||||
\ argmemonly
|
||||
\ arm_aapcscc
|
||||
\ arm_aapcs_vfpcc
|
||||
\ arm_apcscc
|
||||
\ asm
|
||||
\ atomic
|
||||
\ available_externally
|
||||
\ blockaddress
|
||||
\ builtin
|
||||
\ byval
|
||||
\ c
|
||||
\ catch
|
||||
\ caller
|
||||
\ cc
|
||||
\ ccc
|
||||
\ cleanup
|
||||
\ coldcc
|
||||
\ comdat
|
||||
\ common
|
||||
\ constant
|
||||
\ datalayout
|
||||
\ declare
|
||||
\ default
|
||||
\ define
|
||||
\ deplibs
|
||||
\ dereferenceable
|
||||
\ distinct
|
||||
\ dllexport
|
||||
\ dllimport
|
||||
\ dso_local
|
||||
\ dso_preemptable
|
||||
\ except
|
||||
\ external
|
||||
\ externally_initialized
|
||||
\ extern_weak
|
||||
\ fastcc
|
||||
\ filter
|
||||
\ from
|
||||
\ gc
|
||||
\ global
|
||||
\ hhvmcc
|
||||
\ hhvm_ccc
|
||||
\ hidden
|
||||
\ initialexec
|
||||
\ inlinehint
|
||||
\ inreg
|
||||
\ inteldialect
|
||||
\ intel_ocl_bicc
|
||||
\ internal
|
||||
\ linkonce
|
||||
\ linkonce_odr
|
||||
\ localdynamic
|
||||
\ localexec
|
||||
\ local_unnamed_addr
|
||||
\ minsize
|
||||
\ module
|
||||
\ monotonic
|
||||
\ msp430_intrcc
|
||||
\ musttail
|
||||
\ naked
|
||||
\ nest
|
||||
\ noalias
|
||||
\ nobuiltin
|
||||
\ nocapture
|
||||
\ noimplicitfloat
|
||||
\ noinline
|
||||
\ nonlazybind
|
||||
\ nonnull
|
||||
\ norecurse
|
||||
\ noredzone
|
||||
\ noreturn
|
||||
\ nounwind
|
||||
\ optnone
|
||||
\ optsize
|
||||
\ personality
|
||||
\ private
|
||||
\ protected
|
||||
\ ptx_device
|
||||
\ ptx_kernel
|
||||
\ readnone
|
||||
\ readonly
|
||||
\ release
|
||||
\ returned
|
||||
\ returns_twice
|
||||
\ sanitize_address
|
||||
\ sanitize_memory
|
||||
\ sanitize_thread
|
||||
\ section
|
||||
\ seq_cst
|
||||
\ sideeffect
|
||||
\ signext
|
||||
\ syncscope
|
||||
\ source_filename
|
||||
\ speculatable
|
||||
\ spir_func
|
||||
\ spir_kernel
|
||||
\ sret
|
||||
\ ssp
|
||||
\ sspreq
|
||||
\ sspstrong
|
||||
\ strictfp
|
||||
\ swiftcc
|
||||
\ swiftself
|
||||
\ tail
|
||||
\ target
|
||||
\ thread_local
|
||||
\ to
|
||||
\ triple
|
||||
\ unnamed_addr
|
||||
\ unordered
|
||||
\ uselistorder
|
||||
\ uselistorder_bb
|
||||
\ uwtable
|
||||
\ volatile
|
||||
\ weak
|
||||
\ weak_odr
|
||||
\ within
|
||||
\ writeonly
|
||||
\ x86_64_sysvcc
|
||||
\ win64cc
|
||||
\ x86_fastcallcc
|
||||
\ x86_stdcallcc
|
||||
\ x86_thiscallcc
|
||||
\ zeroext
|
||||
|
||||
" Obsolete keywords.
|
||||
syn keyword llvmError getresult begin end
|
||||
|
||||
" Misc syntax.
|
||||
syn match llvmNoName /[%@!]\d\+\>/
|
||||
syn match llvmNumber /-\?\<\d\+\>/
|
||||
syn match llvmFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
|
||||
syn match llvmFloat /\<0x\x\+\>/
|
||||
syn keyword llvmBoolean true false
|
||||
syn keyword llvmConstant zeroinitializer undef null none
|
||||
syn match llvmComment /;.*$/
|
||||
syn region llvmString start=/"/ skip=/\\"/ end=/"/
|
||||
syn match llvmLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
|
||||
syn match llvmIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/
|
||||
|
||||
" Named metadata and specialized metadata keywords.
|
||||
syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*$/
|
||||
syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/
|
||||
syn match llvmType /!\zs\a\+\ze\s*(/
|
||||
syn match llvmConstant /\<DW_TAG_[a-z_]\+\>/
|
||||
syn match llvmConstant /\<DW_ATE_[a-zA-Z_]\+\>/
|
||||
syn match llvmConstant /\<DW_OP_[a-zA-Z0-9_]\+\>/
|
||||
syn match llvmConstant /\<DW_LANG_[a-zA-Z0-9_]\+\>/
|
||||
syn match llvmConstant /\<DW_VIRTUALITY_[a-z_]\+\>/
|
||||
syn match llvmConstant /\<DIFlag[A-Za-z]\+\>/
|
||||
|
||||
" Syntax-highlight lit test commands and bug numbers.
|
||||
syn match llvmSpecialComment /;\s*PR\d*\s*$/
|
||||
syn match llvmSpecialComment /;\s*REQUIRES:.*$/
|
||||
syn match llvmSpecialComment /;\s*RUN:.*$/
|
||||
syn match llvmSpecialComment /;\s*CHECK:.*$/
|
||||
syn match llvmSpecialComment "\v;\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
|
||||
syn match llvmSpecialComment /;\s*XFAIL:.*$/
|
||||
|
||||
if version >= 508 || !exists("did_c_syn_inits")
|
||||
if version < 508
|
||||
let did_c_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink llvmType Type
|
||||
HiLink llvmStatement Statement
|
||||
HiLink llvmNumber Number
|
||||
HiLink llvmComment Comment
|
||||
HiLink llvmString String
|
||||
HiLink llvmLabel Label
|
||||
HiLink llvmKeyword Keyword
|
||||
HiLink llvmBoolean Boolean
|
||||
HiLink llvmFloat Float
|
||||
HiLink llvmNoName Identifier
|
||||
HiLink llvmConstant Constant
|
||||
HiLink llvmSpecialComment SpecialComment
|
||||
HiLink llvmError Error
|
||||
HiLink llvmIdentifier Identifier
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "llvm"
|
58
syntax/tablegen.vim
Normal file
58
syntax/tablegen.vim
Normal file
@ -0,0 +1,58 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'llvm') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim syntax file
|
||||
" Language: TableGen
|
||||
" Maintainer: The LLVM team, http://llvm.org/
|
||||
" Version: $Revision$
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" May be changed if you have a really slow machine
|
||||
syntax sync minlines=100
|
||||
|
||||
syn case match
|
||||
|
||||
syn keyword tgKeyword def let in code dag field include defm foreach
|
||||
syn keyword tgType class int string list bit bits multiclass
|
||||
|
||||
syn match tgNumber /\<\d\+\>/
|
||||
syn match tgNumber /\<\d\+\.\d*\>/
|
||||
syn match tgNumber /\<0b[01]\+\>/
|
||||
syn match tgNumber /\<0x[0-9a-fA-F]\+\>/
|
||||
syn region tgString start=/"/ skip=/\\"/ end=/"/ oneline
|
||||
|
||||
syn region tgCode start=/\[{/ end=/}\]/
|
||||
|
||||
syn keyword tgTodo contained TODO FIXME
|
||||
syn match tgComment /\/\/.*$/ contains=tgTodo
|
||||
" Handle correctly imbricated comment
|
||||
syn region tgComment2 matchgroup=tgComment2 start=+/\*+ end=+\*/+ contains=tgTodo,tgComment2
|
||||
|
||||
if version >= 508 || !exists("did_c_syn_inits")
|
||||
if version < 508
|
||||
let did_c_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink tgKeyword Statement
|
||||
HiLink tgType Type
|
||||
HiLink tgNumber Number
|
||||
HiLink tgComment Comment
|
||||
HiLink tgComment2 Comment
|
||||
HiLink tgString String
|
||||
" May find a better Hilight group...
|
||||
HiLink tgCode Special
|
||||
HiLink tgTodo Todo
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "tablegen"
|
Loading…
Reference in New Issue
Block a user