diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:44:32 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:44:32 +0000 |
commit | 5a5ac124e1efaf208671f01c46edb15f29ed2a0b (patch) | |
tree | a6140557876943cdd800ee997c9317283394b22c /utils/vim | |
parent | f03b5bed27d0d2eafd68562ce14f8b5e3f1f0801 (diff) | |
download | src-5a5ac124e1efaf208671f01c46edb15f29ed2a0b.tar.gz src-5a5ac124e1efaf208671f01c46edb15f29ed2a0b.zip |
Notes
Diffstat (limited to 'utils/vim')
-rw-r--r-- | utils/vim/README | 33 | ||||
-rw-r--r-- | utils/vim/ftdetect/llvm-lit.vim | 1 | ||||
-rw-r--r-- | utils/vim/ftdetect/llvm.vim | 1 | ||||
-rw-r--r-- | utils/vim/ftdetect/tablegen.vim | 1 | ||||
-rw-r--r-- | utils/vim/ftplugin/llvm.vim | 11 | ||||
-rw-r--r-- | utils/vim/ftplugin/tablegen.vim | 12 | ||||
-rw-r--r-- | utils/vim/indent/llvm.vim | 72 | ||||
-rw-r--r-- | utils/vim/syntax/llvm.vim (renamed from utils/vim/llvm.vim) | 8 | ||||
-rw-r--r-- | utils/vim/syntax/tablegen.vim (renamed from utils/vim/tablegen.vim) | 2 |
9 files changed, 112 insertions, 29 deletions
diff --git a/utils/vim/README b/utils/vim/README index bca25bfe6127..1fe00992b0ab 100644 --- a/utils/vim/README +++ b/utils/vim/README @@ -1,33 +1,12 @@ -*- llvm/utils/vim/README -*- -These are syntax highlighting files for the VIM editor. Included are: +This directory contains settings for the vim editor to work on llvm *.ll and +tablegen *.td files. It comes with filetype detection rules in the (ftdetect), +syntax highlighting (syntax), some minimal sensible default settings (ftplugin) +and indentation plugins (indent). -* llvm.vim - - Syntax highlighting mode for LLVM assembly files. To use, copy `llvm.vim' to - ~/.vim/syntax and add this code to your ~/.vimrc : - - augroup filetype - au! BufRead,BufNewFile *.ll set filetype=llvm - augroup END - -* tablegen.vim - - Syntax highlighting mode for TableGen description files. To use, copy - `tablegen.vim' to ~/.vim/syntax and add this code to your ~/.vimrc : - - augroup filetype - au! BufRead,BufNewFile *.td set filetype=tablegen - augroup END - - -If you prefer, instead of making copies you can make symlinks from -~/.vim/syntax/... to the syntax files in your LLVM source tree. Apparently -this did not work with older versions of vim however, so if this doesn't -work you may need to make actual copies of the files. - -Another option, if you do not already have a ~/.vim/syntax directory, is -to symlink ~/.vim/syntax itself to llvm/utils/vim . +To install copy all subdirectories to your $HOME/.vim or if you prefer create +symlinks to the files here. Do not copy the vimrc file here it is only meant as an inspiration and starting point for those working on llvm c++ code. Note: If you notice missing or incorrect syntax highlighting, please contact <llvmbugs [at] cs.uiuc.edu>; if you wish to provide a patch to improve the diff --git a/utils/vim/ftdetect/llvm-lit.vim b/utils/vim/ftdetect/llvm-lit.vim new file mode 100644 index 000000000000..fa651e1268cb --- /dev/null +++ b/utils/vim/ftdetect/llvm-lit.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile lit.*cfg set filetype=python diff --git a/utils/vim/ftdetect/llvm.vim b/utils/vim/ftdetect/llvm.vim new file mode 100644 index 000000000000..161ceb2bd559 --- /dev/null +++ b/utils/vim/ftdetect/llvm.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.ll set filetype=llvm diff --git a/utils/vim/ftdetect/tablegen.vim b/utils/vim/ftdetect/tablegen.vim new file mode 100644 index 000000000000..95efa6efdd0a --- /dev/null +++ b/utils/vim/ftdetect/tablegen.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.td set filetype=tablegen diff --git a/utils/vim/ftplugin/llvm.vim b/utils/vim/ftplugin/llvm.vim new file mode 100644 index 000000000000..04bb9e001696 --- /dev/null +++ b/utils/vim/ftplugin/llvm.vim @@ -0,0 +1,11 @@ +" 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 diff --git a/utils/vim/ftplugin/tablegen.vim b/utils/vim/ftplugin/tablegen.vim new file mode 100644 index 000000000000..cfae846c818b --- /dev/null +++ b/utils/vim/ftplugin/tablegen.vim @@ -0,0 +1,12 @@ +" 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 diff --git a/utils/vim/indent/llvm.vim b/utils/vim/indent/llvm.vim new file mode 100644 index 000000000000..d1d8c83d1186 --- /dev/null +++ b/utils/vim/indent/llvm.vim @@ -0,0 +1,72 @@ +" 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 diff --git a/utils/vim/llvm.vim b/utils/vim/syntax/llvm.vim index f767fda16f87..c8e73cd94a57 100644 --- a/utils/vim/llvm.vim +++ b/utils/vim/syntax/llvm.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: llvm " Maintainer: The LLVM team, http://llvm.org/ -" Version: $Revision: 225830 $ +" Version: $Revision: 235369 $ if version < 600 syntax clear @@ -77,6 +77,12 @@ syn match llvmIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/ 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 dejagnu test commands. syn match llvmSpecialComment /;\s*RUN:.*$/ diff --git a/utils/vim/tablegen.vim b/utils/vim/syntax/tablegen.vim index 40d8d78bba12..21f484893353 100644 --- a/utils/vim/tablegen.vim +++ b/utils/vim/syntax/tablegen.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: TableGen " Maintainer: The LLVM team, http://llvm.org/ -" Version: $Revision: 151164 $ +" Version: $Revision: 235369 $ if version < 600 syntax clear |