Added indendation
This commit is contained in:
parent
3b485d1a87
commit
1a25f9aa01
6 changed files with 88 additions and 21 deletions
31
README.md
31
README.md
|
|
@ -5,13 +5,8 @@ Nim support for Neovim
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
- [x] Add global options for user
|
- [x] Add global options for user
|
||||||
- [ ] Indendation
|
|
||||||
|
|
||||||
- [ ] Doc
|
- [x] Indendation
|
||||||
- [ ] Bindings
|
|
||||||
- [ ] Options
|
|
||||||
- [ ] Commands
|
|
||||||
- [ ] Using with other plugins
|
|
||||||
|
|
||||||
- [ ] Syntax
|
- [ ] Syntax
|
||||||
- [x] Keywords
|
- [x] Keywords
|
||||||
|
|
@ -21,12 +16,8 @@ Nim support for Neovim
|
||||||
- [x] Highlight variable names semantically
|
- [x] Highlight variable names semantically
|
||||||
- [ ] Multiline comments
|
- [ ] Multiline comments
|
||||||
|
|
||||||
- [ ] File based configuration
|
- [x] Compiler support
|
||||||
- [ ] Read project file
|
- [x] Make with nim check
|
||||||
- [ ] Create project file
|
|
||||||
|
|
||||||
- [ ] Compiler support
|
|
||||||
- [ ] Make with nim check
|
|
||||||
|
|
||||||
- [x] Nimsuggest
|
- [x] Nimsuggest
|
||||||
- [x] Usages
|
- [x] Usages
|
||||||
|
|
@ -44,9 +35,6 @@ Nim support for Neovim
|
||||||
- [x] NimRenameSymbol
|
- [x] NimRenameSymbol
|
||||||
- [ ] NimRenameSymbolProject
|
- [ ] NimRenameSymbolProject
|
||||||
|
|
||||||
- [ ] Misc
|
|
||||||
- [ ] Airline integration
|
|
||||||
|
|
||||||
- [ ] IDE features
|
- [ ] IDE features
|
||||||
- [x] Neomake
|
- [x] Neomake
|
||||||
- [x] View online documentation
|
- [x] View online documentation
|
||||||
|
|
@ -119,6 +107,19 @@ Nim support for Neovim
|
||||||
- [ ] NimRenameSymbol
|
- [ ] NimRenameSymbol
|
||||||
- [ ] NimRenameSymbolProject
|
- [ ] NimRenameSymbolProject
|
||||||
|
|
||||||
|
- [ ] Doc
|
||||||
|
- [ ] Bindings
|
||||||
|
- [ ] Options
|
||||||
|
- [ ] Commands
|
||||||
|
- [ ] Using with other plugins
|
||||||
|
|
||||||
|
- [ ] File based configuration
|
||||||
|
- [ ] Read project file
|
||||||
|
- [ ] Create project file
|
||||||
|
|
||||||
|
- [ ] Misc
|
||||||
|
- [ ] Airline integration
|
||||||
|
|
||||||
|
|
||||||
# Roadmap
|
# Roadmap
|
||||||
## v0.1
|
## v0.1
|
||||||
|
|
|
||||||
0
autoload/features/repl.vim
Normal file
0
autoload/features/repl.vim
Normal file
|
|
@ -86,7 +86,7 @@ function! s:NimHighlighter.on_exit()
|
||||||
|
|
||||||
if has_key(s:highlights, ctype)
|
if has_key(s:highlights, ctype)
|
||||||
if has_key(semantics_set, ctype)
|
if has_key(semantics_set, ctype)
|
||||||
call add(b:highlights, matchaddpos("Semantic" . util#djb(strpart(str, c - 1, s)) % 20, [[line, c, s]]))
|
call add(b:highlights, matchaddpos("Semantic" . abs(util#djb(strpart(str, c - 1, s))) % 20, [[line, c, s]]))
|
||||||
else
|
else
|
||||||
call add(b:highlights, matchaddpos(s:highlights[ctype], [[line, c, s]]))
|
call add(b:highlights, matchaddpos(s:highlights[ctype], [[line, c, s]]))
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
if exists("s:loaded")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:loaded = 1
|
|
||||||
|
|
@ -3,11 +3,18 @@ if exists("b:loaded")
|
||||||
endif
|
endif
|
||||||
let b:loaded = 1
|
let b:loaded = 1
|
||||||
|
|
||||||
|
setlocal iskeyword=a-z,A-Z,48-57,128-255,_
|
||||||
setlocal formatoptions-=t formatoptions+=l
|
setlocal formatoptions-=t formatoptions+=l
|
||||||
setlocal comments=s1:#[,mb:#,ex:]#,:#
|
setlocal comments=s1:#[,mb:#,ex:]#,:#,:##
|
||||||
setlocal commentstring=#\ %s
|
setlocal commentstring=#\ %s
|
||||||
setlocal expandtab
|
setlocal expandtab
|
||||||
setlocal omnifunc=omni#nim
|
setlocal omnifunc=omni#nim
|
||||||
|
setlocal makeprg=nim\ c\ --verbosity:0\ --colors:off\ %
|
||||||
|
setlocal errorformat=
|
||||||
|
\%-GHint:\ %m,
|
||||||
|
\%A%f(%l\\,\ %c)\ Hint:\ %m,
|
||||||
|
\%E%f(%l\\,\ %c)\ Error:\ %m,
|
||||||
|
\%W%f(%l\\,\ %c)\ Warning:\ %m
|
||||||
|
|
||||||
command! NimDefinition :call features#definition#run()
|
command! NimDefinition :call features#definition#run()
|
||||||
command! NimInfo :call features#info#run()
|
command! NimInfo :call features#info#run()
|
||||||
|
|
|
||||||
63
indent/nim.vim
Normal file
63
indent/nim.vim
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
" if exists("b:loaded")
|
||||||
|
" finish
|
||||||
|
" endif
|
||||||
|
" let b:loaded = 1
|
||||||
|
|
||||||
|
setlocal nolisp
|
||||||
|
setlocal autoindent
|
||||||
|
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif
|
||||||
|
setlocal indentexpr=NimIndent()
|
||||||
|
|
||||||
|
function! Down()
|
||||||
|
return indent(prevnonblank(v:lnum - 1)) - &tabstop
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! Up()
|
||||||
|
return (indent(prevnonblank(v:lnum - 1)) + &tabstop)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! NimIndent()
|
||||||
|
let line = getline(v:lnum)
|
||||||
|
let prev = prevnonblank(v:lnum - 1)
|
||||||
|
let prevempty = getline(v:lnum - 1) =~ '^\s*$'
|
||||||
|
let prev2empty = getline(v:lnum - 2) =~ '^\s*$'
|
||||||
|
let prevl = getline(prev)
|
||||||
|
|
||||||
|
if prev2empty && prevempty
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ '\([:=\[({]\|and\|or\|not\|xor\|shl\|shr\|div\|mod\|in\|notin\|is\|isnot\|of\)\s*$'
|
||||||
|
return Up()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ '\s*\(import\|type\)'
|
||||||
|
return Up()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ '\s*\(const\|var\|let\)\s*$'
|
||||||
|
return Up()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ '\(object\|enum\|object\|concept\|tuple\)\s*$'
|
||||||
|
return Up()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ '^\(const\|var\|let\).*\s*if\s*.*$'
|
||||||
|
return Up()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ ',\s*$'
|
||||||
|
return -1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevempty && prevl =~ '\s*\(result\|return\|break\|continue\|raise\)'
|
||||||
|
return Down()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if prevl =~ '[\])}]\s*$'
|
||||||
|
return Down()
|
||||||
|
endif
|
||||||
|
|
||||||
|
return -1
|
||||||
|
endfunction
|
||||||
Loading…
Add table
Add a link
Reference in a new issue