commit 8d2e220fa4c9f35fea1208c2efb5d54897ed1f56
parent 0f89ae21e748bd21a2077096a3eca45a94941956
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 14 Jun 2019 22:34:40 +0200
Add non-working julia filetype detection
Diffstat:
3 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/.config/vis/lexers/julia.lua b/.config/vis/lexers/julia.lua
@@ -0,0 +1,49 @@
+-- ? LPeg lexer.
+
+local l = require('lexer')
+local token, word_match = l.token, l.word_match
+local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+local M = {_NAME = 'julia'}
+
+-- Whitespace.
+local ws = token(l.WHITESPACE, l.space^1)
+
+-- Comments.
+local comment = token(l.COMMENT, '#' * l.nonnewline_esc^0)
+
+-- Strings.
+local dq_str = P('U')^-1 * l.delimited_range('"', true)
+local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1
+local string = token(l.STRING, triple_dq_str + dq_str)
+
+-- Keywords from `reserved-words` in Julia
+local keyword = token(l.KEYWORD, word_match{
+ 'begin', 'while', 'if', 'for', 'try', 'return', 'break', 'continue',
+ 'function', 'macro', 'quote', 'let', 'local' ', 'global', 'const', 'do',
+ 'struct', 'type', 'immutable', 'importall', 'module', 'baremodule', 'using',
+ 'import', 'export', 'end', 'else', 'catch', 'finally', 'true', 'false'
+})
+
+-- Operators.
+local operator = token(l.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~`'))
+
+M._rules = {
+ {'whitespace', ws},
+ {'keyword', keyword},
+ -- {'function', func},
+ -- {'constant', constant},
+ -- {'self', self},
+ -- {'identifier', identifier},
+ {'comment', comment},
+ -- {'string', string},
+ -- {'number', number},
+ -- {'decorator', decorator},
+ {'operator', operator},
+}
+
+M._tokenstyles = {
+
+}
+
+return M+
\ No newline at end of file
diff --git a/.config/vis/myfiletype.lua b/.config/vis/myfiletype.lua
@@ -0,0 +1,5 @@
+require("plugins/filetype")
+
+vis.ftdetect.filetypes["julia"] = {
+ ext = { "%.jl$" },
+}+
\ No newline at end of file
diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua
@@ -1,4 +1,5 @@
require('vis')
+require('myfiletype')
require('plugins/vis-commentary')
require('plugins/fzf-mru')
require('snippets')