aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorchedSammy <38820196+TorchedSammy@users.noreply.github.com>2022-04-24 16:00:34 -0400
committerTorchedSammy <38820196+TorchedSammy@users.noreply.github.com>2022-04-24 16:00:34 -0400
commitb0cb097bbb01eef65ae2099844d682a105d91d88 (patch)
tree6f9cf377a37de4937198b6e3758fe0b34f45a37b
parent7a408d013259e867a45af8cf561057c8c1635855 (diff)
parentf2bd9349a5a286cf6c0612225336d7015f86cba0 (diff)
downloadlite-xl-plugins-b0cb097bbb01eef65ae2099844d682a105d91d88.tar.gz
lite-xl-plugins-b0cb097bbb01eef65ae2099844d682a105d91d88.zip
docs: resolve merge conflict, bring in latest changes
-rw-r--r--README.md22
-rw-r--r--plugins/language_cpp.lua110
-rw-r--r--plugins/language_rivet.lua (renamed from plugins/language_glaz.lua)55
-rw-r--r--plugins/typingspeed.lua93
4 files changed, 228 insertions, 52 deletions
diff --git a/README.md b/README.md
index b2a36ea..c3867ef 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,19 @@
+# Lite XL plugins
Plugins for the [Lite XL text editor](https://github.com/lite-xl/lite-xl), originally forked from the [lite plugins repository](https://github.com/rxi/lite-plugins).
+If you can't find a plugin that suits your needs,
+check if someone has already created an issue about it,
+otherwise feel free to create one yourself.
+
+## How to install
+To install a plugin:
+
+* If the plugin links to a repository, follow its `README`.
+* If the plugin is a single file, drop it directly in:
+ * Linux `~/.config/lite-xl/plugins/`
+ * MacOS `~/.config/lite-xl/plugins/`
+ * Windows `C:\Users\(username)\.config\lite-xl\plugins\`
+
*Note: if you make a pull request, the table should be updated and kept in
alphabetical order. If your plugin is large (or you'd otherwise prefer it to
have its own repo), the table can simply be updated to add a link to the repo;
@@ -46,6 +60,7 @@ to something other than a raw file it should be marked with an asterisk.*
| [`indentguide`](plugins/indentguide.lua?raw=1) | Adds indent guides *([screenshot](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png))* |
| [`Kinc Projects`](https://github.com/Kode-Community/kinc_plugin)\* | Adds [Kinc](https://github.com/Kode/Kinc) Project generation with basic build commands(depends on [`console`](https://github.com/franko/console)) |
| [`language_angelscript`](plugins/language_angelscript.lua?raw=1) | Syntax for the [Angelscript](https://www.angelcode.com/angelscript/) programming language |
+| [`language_autohotkey`](https://github.com/devPnal/lite-plugin-autohotkey)\* | Syntax for the [AutoHotkey](https://www.autohotkey.com) programming language |
| [`language_batch`](plugins/language_batch.lua?raw=1) | Syntax for Windows [Batch Files](https://en.wikipedia.org/wiki/Batch_file) |
| [`language_bib`](plugins/language_bib.lua?raw=1) | Syntax for [BibTex](https://en.wikipedia.org/wiki/BibTeX) files |
| [`language_cmake`](plugins/language_cmake.lua?raw=1) | Syntax for the CMake build system language |
@@ -61,7 +76,6 @@ to something other than a raw file it should be marked with an asterisk.*
| [`language_fennel`](plugins/language_fennel.lua?raw=1) | Syntax for the [fennel](https://fennel-lang.org) programming language |
| [`language_fstab`](plugins/language_fstab.lua?raw=1) | Syntax for the [fstab](https://en.wikipedia.org/wiki/Fstab) config files |
| [`language_gdscript`](plugins/language_gdscript.lua?raw=1) | Syntax for the [Godot Engine](https://godotengine.org/)'s GDScript scripting language |
-| [`language_glaz`](plugins/language_glaz.lua?raw=1) | Syntax for the [Glaz](https://github.com/glaz-lang/glaz) programming language |
| [`language_glsl`](plugins/language_glsl.lua?raw=1) | Syntax for the [GLSL](https://www.khronos.org/registry/OpenGL/specs/gl/) programming language |
| [`language_gmi`](plugins/language_gmi.lua?raw=1) | Syntax for the [Gemtext](https://gemini.circumlunar.space/docs/gemtext.gmi) markup language |
| [`language_go`](plugins/language_go.lua?raw=1) | Syntax for the [Go](https://golang.org/) programming language |
@@ -93,6 +107,7 @@ to something other than a raw file it should be marked with an asterisk.*
| [`language_psql`](plugins/language_psql.lua?raw=1) | Syntax for the postgresql database access language |
| [`language_r`](plugins/language_R.lua?raw=1) | Syntax for [R](https://www.r-project.org/) scripting language |
| [`language_rescript`](plugins/language_rescript.lua?raw=1) | Syntax for the [ReScript](https://rescript-lang.org/) programming language |
+| [`language_rivet`](plugins/language_rivet.lua?raw=1) | Syntax for the [Rivet](https://github.com/rivet-lang/rivet) programming language |
| [`language_ruby`](plugins/language_ruby.lua?raw=1) | Syntax for the [Ruby](https://www.ruby-lang.org/) programming language |
| [`language_rust`](plugins/language_rust.lua?raw=1) | Syntax for the [Rust](https://rust-lang.org/) programming language |
| [`language_sass`](plugins/language_sass.lua?raw=1) | Syntax for the [Sass](https://sass-lang.com/) CSS preprocessor |
@@ -115,6 +130,7 @@ to something other than a raw file it should be marked with an asterisk.*
| [`lint+`](https://github.com/liquid600pgm/lintplus)\* | Advanced linter with ErrorLens-like error reporting. Compatible with linters made for `linter` *([screenshot](https://raw.githubusercontent.com/liquid600pgm/lintplus/master/screenshots/1.png))* |
| [`linter`](https://github.com/drmargarido/linters)\* | Linters for multiple languages |
| [`litepresence`](https://github.com/TorchedSammy/Litepresence)\* | Discord rich presence for Lite XL (display file editing in Discord) |
+| [`lsp`](https://github.com/lite-xl/lite-xl-lsp)\* | Provides code completion (also known as IntelliSense) using the Language Server Protocol |
| [`lspkind`](https://github.com/TorchedSammy/lite-xl-lspkind)\* | Completion menu kind/type icons for Lite XL LSP |
| [`macmodkeys`](plugins/macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt` |
| [`markers`](plugins/markers.lua?raw=1) | Add markers to docs and jump between them quickly *([screenshot](https://user-images.githubusercontent.com/3920290/82252149-5faaa200-9946-11ea-9199-bea2efb7ee23.png))* |
@@ -142,12 +158,14 @@ to something other than a raw file it should be marked with an asterisk.*
| [`tabnumbers`](plugins/tabnumbers.lua?raw=1) | Displays tab numbers from 1–9 next to their names \*([screenshot](https://user-images.githubusercontent.com/16415678/101285362-007a8500-37e5-11eb-869b-c10eb9d9d902.png)) |
| [`texcompile`](plugins/texcompile.lua?raw=1) | Compile Tex files into PDF |
| [`theme16`](https://github.com/monolifed/theme16)\* | Theme manager with base16 themes |
-| [`themescheduler`](https://github.com/BenStigsen/lite-config/blob/main/plugins/themescheduler.lua?raw=1) | Schedule themes to be used at certain times |
| [`themeselect`](plugins/themeselect.lua?raw=1) | Select a theme based on filename of active document |
| [`titleize`](plugins/titleize.lua?raw=1) | Titleizes selected string (`hello world` => `Hello World`) |
| [`todotreeview`](https://github.com/drmargarido/TodoTreeView)\* | Todo tree viewer for annotations in code like `TODO`, `BUG`, `FIX`, `IMPROVEMENT` |
| [`togglesnakecamel`](plugins/togglesnakecamel.lua?raw=1) | Toggles symbols between `snake_case` and `camelCase` |
+| [`treeview-menu-extender`](https://github.com/juliardi/lite-xl-treeview-menu-extender)\* | Extend Lite XL's treeview menu *([screenshot](https://raw.githubusercontent.com/juliardi/lite-xl-treeview-menu-extender/main/screenshot.png))* |
+| [`typingspeed`](plugins/typingspeed.lua?raw=1) | Displays your current typing speed in characters and words per minute in the status bar |
| [`unboundedscroll`](plugins/unboundedscroll.lua?raw=1) | Allows scrolling outside the bounds of a document |
| [`updatechecker`](https://github.com/vincens2005/lite-xl-updatechecker)\* | Automatically checks for updates and notifies you |
| [`vibe`](https://github.com/eugenpt/lite-xl-vibe)\* | VI(vim?) bindings with a hint of DOOM Emacs, for lite-xl |
| [`visu`](https://github.com/TorchedSammy/Visu)\* | Audio visualizer for Lite XL |
+| [`widget`](https://github.com/lite-xl/lite-xl-widgets)\* | Plugin library that provides a set of re-usable components to more easily write UI elements for your plugins |
diff --git a/plugins/language_cpp.lua b/plugins/language_cpp.lua
index a0eb076..b1afa0f 100644
--- a/plugins/language_cpp.lua
+++ b/plugins/language_cpp.lua
@@ -1,6 +1,4 @@
-- mod-version:2 -- lite-xl 2.0
-pcall(require, "plugins.language_c")
-
local syntax = require "core.syntax"
syntax.add {
@@ -10,30 +8,89 @@ syntax.add {
"%.c++$", "%.hh$", "%.H$", "%.hxx$", "%.hpp$", "%.h++$"
},
comment = "//",
+ block_comment = { "/*", "*/" },
patterns = {
- { pattern = "//.-\n", type = "comment" },
- { pattern = { "/%*", "%*/" }, type = "comment" },
- { pattern = { '"', '"', '\\' }, type = "string" },
- { pattern = { "'", "'", '\\' }, type = "string" },
- { pattern = "-?0x%x+", type = "number" },
- { pattern = "-?%d+[%d%.eE]*f?", type = "number" },
- { pattern = "-?%.?%d+f?", type = "number" },
- {
- pattern = "#include%s+()<.->",
- type = { "keyword", "string" }
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "0x%x+", type = "number" },
+ { pattern = "%d+[%d%.'eE]*f?", type = "number" },
+ { pattern = "%.?%d+f?", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|:&]", type = "operator" },
+ { pattern = "##", type = "operator" },
+ { pattern = "struct%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "class%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "union%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "namespace%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ -- static declarations
+ { pattern = "static()%s+()inline",
+ type = { "keyword", "normal", "keyword" }
+ },
+ { pattern = "static()%s+()const",
+ type = { "keyword", "normal", "keyword" }
+ },
+ { pattern = "static()%s+()[%a_][%w_]*",
+ type = { "keyword", "normal", "literal" }
+ },
+ -- match method type declarations
+ { pattern = "[%a_][%w_]*()%s*()%**()%s*()[%a_][%w_]*()%s*()::",
+ type = {
+ "literal", "normal", "operator", "normal",
+ "literal", "normal", "operator"
+ }
+ },
+ -- match function type declarations
+ { pattern = "[%a_][%w_]*()%*+()%s+()[%a_][%w_]*%f[%(]",
+ type = { "literal", "operator", "normal", "function" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()%*+()[%a_][%w_]*%f[%(]",
+ type = { "literal", "normal", "operator", "function" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()[%a_][%w_]*%f[%(]",
+ type = { "literal", "normal", "function" }
+ },
+ -- match variable type declarations
+ { pattern = "[%a_][%w_]*()%*+()%s+()[%a_][%w_]*",
+ type = { "literal", "operator", "normal", "normal" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()%*+()[%a_][%w_]*",
+ type = { "literal", "normal", "operator", "normal" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()[%a_][%w_]*()%s*()[;,%[%)]",
+ type = { "literal", "normal", "normal", "normal", "normal" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()[%a_][%w_]*()%s*()=",
+ type = { "literal", "normal", "normal", "normal", "operator" }
+ },
+ { pattern = "[%a_][%w_]*()&()%s+()[%a_][%w_]*",
+ type = { "literal", "operator", "normal", "normal" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()&()[%a_][%w_]*",
+ type = { "literal", "normal", "operator", "normal" }
},
- { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
- { pattern = "[%a_][%w_]*%f[(]", type = "function" },
-- Match scope operator element access
- { pattern = "[%a_][%w_]*[%s]*%f[:]",type = "literal" },
- -- Uppercase constants of at least 3 characters in len
- { pattern = "%u[%u_][%u%d_]+", type = "number" },
+ { pattern = "[%a_][%w_]*()%s*()::",
+ type = { "literal", "normal", "operator" }
+ },
+ -- Uppercase constants of at least 2 chars in len
+ { pattern = "_?%u[%u_][%u%d_]*%f[%s%+%*%-%.%)%]}%?%^%%=/<>~|&;:,!]",
+ type = "number"
+ },
-- Magic constants
- { pattern = "__[%u]+__", type = "number" },
- -- Somehow makes macros properly work
- { pattern = "#[%a_][%w_]*", type = "symbol" },
+ { pattern = "__[%u%l]+__", type = "number" },
+ -- all other functions
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ -- Macros
+ { pattern = "^%s*#%s*define%s+()[%a_][%a%d_]*",
+ type = { "keyword", "symbol" }
+ },
+ { pattern = "#%s*include%s+()<.->",
+ type = { "keyword", "string" }
+ },
+ { pattern = "%f[#]#%s*[%a_][%w_]*", type = "keyword" },
-- Everything else to make the tokenizer work properly
- { pattern = "[%a_][%w_]*", type = "symbol" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
},
symbols = {
["alignof"] = "keyword",
@@ -84,6 +141,7 @@ syntax.add {
["typeid"] = "keyword",
["typename"] = "keyword",
["mutable"] = "keyword",
+ ["override"] = "keyword",
["virtual"] = "keyword",
["using"] = "keyword",
["namespace"] = "keyword",
@@ -100,7 +158,7 @@ syntax.add {
["continue"] = "keyword",
["return"] = "keyword",
["goto"] = "keyword",
- ["struct"] = "keyword2",
+ ["struct"] = "keyword",
["union"] = "keyword",
["typedef"] = "keyword",
["enum"] = "keyword",
@@ -113,7 +171,7 @@ syntax.add {
["case"] = "keyword",
["default"] = "keyword",
["auto"] = "keyword",
- ["void"] = "keyword",
+ ["void"] = "keyword2",
["int"] = "keyword2",
["short"] = "keyword2",
["long"] = "keyword2",
@@ -122,13 +180,13 @@ syntax.add {
["char"] = "keyword2",
["unsigned"] = "keyword2",
["bool"] = "keyword2",
- ["true"] = "keyword2",
- ["false"] = "keyword2",
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["NULL"] = "literal",
["wchar_t"] = "keyword2",
["char8_t"] = "keyword2",
["char16_t"] = "keyword2",
["char32_t"] = "keyword2",
- ["NULL"] = "literal",
["#include"] = "keyword",
["#if"] = "keyword",
["#ifdef"] = "keyword",
diff --git a/plugins/language_glaz.lua b/plugins/language_rivet.lua
index bfff246..b291749 100644
--- a/plugins/language_glaz.lua
+++ b/plugins/language_rivet.lua
@@ -1,17 +1,20 @@
-- mod-version:2 -- lite-xl 2.0
+-- Syntax highlighting for the Rivet programming language.
+-- by StunxFS :)
+
local syntax = require "core.syntax"
syntax.add {
- name = "Glaz",
- files = {"%.glaz$", "^glaz%.proj$"},
+ name = "Rivet",
+ files = {"%.ri$"},
comment = "//",
block_comment = {"/*", "*/"},
patterns = {
{pattern = "//.-\n", type = "comment"},
{pattern = {"/%*", "%*/"}, type = "comment"},
{pattern = {'"', '"', "\\"}, type = "string"},
- {pattern = "'.'", type = "string"},
+ {pattern = "'\\?.'", type = "string"},
{pattern = "0b[01_]+", type = "number"},
{pattern = "0o[0-7_]+", type = "number"},
{pattern = "0x[%x_]+", type = "number"},
@@ -25,52 +28,57 @@ syntax.add {
{pattern = "[%a_][%w_]*%f[(]", type = "function"},
{pattern = "[%a_][%w_]*!%f[%[(]", type = "keyword2"},
{pattern = "[%a_][%w_]*", type = "symbol"},
- {pattern = {"@%[", "%]"}, type = "keyword"},
{pattern = "%$%s?[%a_][%w_]*", type = "keyword"},
{pattern = "#%s?include%s()<.->", type = {"keyword", "string"}},
{pattern = "#%s?[%a_][%w_]*", type = "keyword"}
},
symbols = {
- ["mod"] = "keyword",
- ["src"] = "keyword",
["extern"] = "keyword",
- ["interface"] = "keyword",
+ ["use"] = "keyword",
+
+ ["pub"] = "keyword",
+ ["as"] = "keyword",
+
+ ["pkg"] = "keyword",
+ ["mod"] = "keyword",
+ ["const"] = "keyword",
+ ["trait"] = "keyword",
["struct"] = "keyword",
["union"] = "keyword",
["type"] = "keyword",
["enum"] = "keyword",
- ["impl"] = "keyword",
["fn"] = "keyword",
["test"] = "keyword",
- ["pub"] = "keyword",
- ["use"] = "keyword",
+ ["impl"] = "keyword",
+
+ ["match"] = "keyword",
["if"] = "keyword",
["elif"] = "keyword",
["else"] = "keyword",
- ["do"] = "keyword",
+ ["loop"] = "keyword",
["while"] = "keyword",
["for"] = "keyword",
- ["loop"] = "keyword",
+
["break"] = "keyword",
["continue"] = "keyword",
["return"] = "keyword",
["raise"] = "keyword",
- ["goto"] = "keyword",
- ["unsafe"] = "keyword",
- ["const"] = "keyword",
+
["let"] = "keyword",
["mut"] = "keyword",
- ["switch"] = "keyword",
- ["defer"] = "keyword",
+ ["unsafe"] = "keyword",
+ ["goto"] = "keyword",
["try"] = "keyword",
["orelse"] = "keyword",
["catch"] = "keyword",
- ["as"] = "keyword",
+ ["cast"] = "keyword",
["is"] = "keyword",
["in"] = "keyword",
- ["and"] = "keyword",
["or"] = "keyword",
+ ["and"] = "keyword",
+
-- types
+ ["bool"] = "keyword2",
["i8"] = "keyword2",
["i16"] = "keyword2",
["i32"] = "keyword2",
@@ -81,20 +89,19 @@ syntax.add {
["u64"] = "keyword2",
["f32"] = "keyword2",
["f64"] = "keyword2",
- ["bool"] = "keyword2",
- ["rune"] = "keyword2",
+ ["char"] = "keyword2",
["isize"] = "keyword2",
["usize"] = "keyword2",
["str"] = "keyword2",
- ["charptr"] = "keyword2",
["rawptr"] = "keyword2",
- ["map"] = "keyword2",
+ ["Self"] = "keyword2",
+
-- literals
["base"] = "literal",
["self"] = "literal",
["true"] = "literal",
["false"] = "literal",
- ["null"] = "literal"
+ ["none"] = "literal"
}
}
diff --git a/plugins/typingspeed.lua b/plugins/typingspeed.lua
new file mode 100644
index 0000000..62e44ef
--- /dev/null
+++ b/plugins/typingspeed.lua
@@ -0,0 +1,93 @@
+-- mod-version:2
+
+local core = require "core"
+local style = require "core.style"
+local common = require "core.common"
+local config = require "core.config"
+local DocView = require "core.docview"
+
+if common["merge"] then
+ config.plugins.typingspeed = common.merge({
+ -- characters that should be counted as word boundary
+ word_boundaries = "[%p%s]",
+ }, config.plugins.keystats)
+else
+ config.plugins.typingspeed = {
+ -- characters that should be counted as word boundary
+ word_boundaries = "[%p%s]",
+ }
+end
+
+local chars = 0
+local chars_last = 0
+local words = 0
+local words_last = 0
+local time_last = 0
+local started_word = false
+local cpm = 0
+local wpm = 0
+
+core.add_thread(function()
+ while true do
+ local t = os.date("*t")
+ if t.sec <= time_last then
+ words_last = words
+ words = 0
+ chars_last = chars
+ chars = 0
+ time_last = t.sec
+ end
+ wpm = words_last * (1-(t.sec)/60) + words
+ cpm = chars_last * (1-(t.sec)/60) + chars
+ coroutine.yield(1)
+ end
+end)
+
+local on_text_input = DocView.on_text_input
+function DocView:on_text_input(text, idx)
+ chars = chars + 1
+ if string.find(text, config.plugins.typingspeed.word_boundaries) then
+ if started_word then
+ words = words + 1
+ started_word = false
+ end
+ else
+ started_word = true
+ end
+ on_text_input(self, text, idx)
+end
+
+if core.status_view["add_item"] then
+ core.status_view:add_item(
+ function()
+ return core.active_view and getmetatable(core.active_view) == DocView
+ end,
+ "keystats:stats",
+ core.status_view.Item.RIGHT,
+ function()
+ return {
+ style.text,
+ string.format("%.0f CPM / %.0f WPM", cpm, wpm)
+ }
+ end,
+ nil,
+ 1,
+ "characters / words per minute"
+ ).separator = core.status_view.separator2
+else
+ local get_items = core.status_view.get_items
+ function core.status_view:get_items()
+ local left, right = get_items(self)
+
+ local t = {
+ style.text, string.format("%.0f CPM / %.0f WPM", cpm, wpm),
+ style.dim, self.separator2
+ }
+
+ for i, item in ipairs(t) do
+ table.insert(right, i, item)
+ end
+
+ return left, right
+ end
+end