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
|
||||
- [x] Add global options for user
|
||||
- [ ] Indendation
|
||||
|
||||
- [ ] Doc
|
||||
- [ ] Bindings
|
||||
- [ ] Options
|
||||
- [ ] Commands
|
||||
- [ ] Using with other plugins
|
||||
- [x] Indendation
|
||||
|
||||
- [ ] Syntax
|
||||
- [x] Keywords
|
||||
|
|
@ -21,12 +16,8 @@ Nim support for Neovim
|
|||
- [x] Highlight variable names semantically
|
||||
- [ ] Multiline comments
|
||||
|
||||
- [ ] File based configuration
|
||||
- [ ] Read project file
|
||||
- [ ] Create project file
|
||||
|
||||
- [ ] Compiler support
|
||||
- [ ] Make with nim check
|
||||
- [x] Compiler support
|
||||
- [x] Make with nim check
|
||||
|
||||
- [x] Nimsuggest
|
||||
- [x] Usages
|
||||
|
|
@ -44,9 +35,6 @@ Nim support for Neovim
|
|||
- [x] NimRenameSymbol
|
||||
- [ ] NimRenameSymbolProject
|
||||
|
||||
- [ ] Misc
|
||||
- [ ] Airline integration
|
||||
|
||||
- [ ] IDE features
|
||||
- [x] Neomake
|
||||
- [x] View online documentation
|
||||
|
|
@ -119,6 +107,19 @@ Nim support for Neovim
|
|||
- [ ] NimRenameSymbol
|
||||
- [ ] NimRenameSymbolProject
|
||||
|
||||
- [ ] Doc
|
||||
- [ ] Bindings
|
||||
- [ ] Options
|
||||
- [ ] Commands
|
||||
- [ ] Using with other plugins
|
||||
|
||||
- [ ] File based configuration
|
||||
- [ ] Read project file
|
||||
- [ ] Create project file
|
||||
|
||||
- [ ] Misc
|
||||
- [ ] Airline integration
|
||||
|
||||
|
||||
# Roadmap
|
||||
## 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(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
|
||||
call add(b:highlights, matchaddpos(s:highlights[ctype], [[line, c, s]]))
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
|
@ -3,11 +3,18 @@ if exists("b:loaded")
|
|||
endif
|
||||
let b:loaded = 1
|
||||
|
||||
setlocal iskeyword=a-z,A-Z,48-57,128-255,_
|
||||
setlocal formatoptions-=t formatoptions+=l
|
||||
setlocal comments=s1:#[,mb:#,ex:]#,:#
|
||||
setlocal comments=s1:#[,mb:#,ex:]#,:#,:##
|
||||
setlocal commentstring=#\ %s
|
||||
setlocal expandtab
|
||||
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! 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