Vim fix, lists and strings size fix
This commit is contained in:
52
.vim/indent/kyn.vim
Normal file
52
.vim/indent/kyn.vim
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Kyn
|
||||||
|
" Maintainer: Gemini
|
||||||
|
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal indentexpr=GetKynIndent()
|
||||||
|
setlocal indentkeys+=={,},0)
|
||||||
|
|
||||||
|
let b:undo_indent = "setlocal indentexpr< indentkeys<"
|
||||||
|
|
||||||
|
" Only define the function once
|
||||||
|
if exists("*GetKynIndent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function GetKynIndent()
|
||||||
|
" Get the line number of the current line
|
||||||
|
let lnum = v:lnum
|
||||||
|
|
||||||
|
" Get the current line
|
||||||
|
let cline = getline(lnum)
|
||||||
|
|
||||||
|
" If the current line has a '}', decrease indent
|
||||||
|
if cline =~ '^\s*}'
|
||||||
|
let lnum = prevnonblank(lnum - 1)
|
||||||
|
return indent(lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Find the previous non-blank line
|
||||||
|
let lnum = prevnonblank(lnum - 1)
|
||||||
|
|
||||||
|
" At the start of the file, no indent
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Get the indent of the previous line
|
||||||
|
let prev_indent = indent(lnum)
|
||||||
|
let prev_line = getline(lnum)
|
||||||
|
|
||||||
|
" If the previous line ends with '{', increase indent
|
||||||
|
if prev_line =~ '{\s*$'
|
||||||
|
return prev_indent + &shiftwidth
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Otherwise, keep the same indent
|
||||||
|
return prev_indent
|
||||||
|
endfunction
|
||||||
@@ -39,7 +39,7 @@ Value handleListGet(const Value& subject, const std::vector<Value>& args) {
|
|||||||
return Value();
|
return Value();
|
||||||
}
|
}
|
||||||
Value accessor = args[0];
|
Value accessor = args[0];
|
||||||
if (accessor.valtype == ValueType::String && accessor.string_val == "size") {
|
if (accessor.valtype == ValueType::Identifier && accessor.string_val == "size") {
|
||||||
return Value((long long)subject.list.size());
|
return Value((long long)subject.list.size());
|
||||||
}
|
}
|
||||||
if (accessor.valtype != ValueType::Int) {
|
if (accessor.valtype != ValueType::Int) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ Value handleStringGet(const Value& subject, const std::vector<Value>& args) {
|
|||||||
}
|
}
|
||||||
Value accessor = args[0];
|
Value accessor = args[0];
|
||||||
if (accessor.valtype != ValueType::Int) {
|
if (accessor.valtype != ValueType::Int) {
|
||||||
if (accessor.valtype == ValueType::String && accessor.string_val == "size") {
|
if (accessor.valtype == ValueType::Identifier && accessor.string_val == "size") {
|
||||||
return Value((long long)subject.string_val.length());
|
return Value((long long)subject.string_val.length());
|
||||||
}
|
}
|
||||||
error("String accessor must be an integer or \"size\"");
|
error("String accessor must be an integer or \"size\"");
|
||||||
|
|||||||
Reference in New Issue
Block a user