From a6e752d1eba6217d8a2f4cac3d170db39e37d713 Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Wed, 27 Oct 2021 13:38:10 +0800 Subject: add smoothcaret.lua --- README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'README.md') diff --git a/README.md b/README.md index 5e40895..cc44cda 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ Plugin | Description [`scalestatus`](plugins/scalestatus.lua?raw=1) | Displays current scale (zoom) in status view (depends on scale plugin) [`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | Highlights regions of code that match the current selection *([screenshot](https://user-images.githubusercontent.com/3920290/80710883-5f597c80-8ae7-11ea-97f0-76dfacc08439.png))* [`smallclock`](plugins/smallclock.lua?raw=1) | Displays the current time in the corner of the status view +*[`smoothcaret`](plugins/smoothcaret.lua?raw=1)* | Smooth caret animation *([gif](https://user-images.githubusercontent.com/20792268/139006049-a0ba6559-88cb-49a7-8077-4822445b4a1f.gif))* [`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically [`spellcheck`](plugins/spellcheck.lua?raw=1) | Underlines misspelt words *([screenshot](https://user-images.githubusercontent.com/3920290/79923973-9caa7400-842e-11ea-85d4-7a196a91ca50.png))* *— note: on Windows a [`words.txt`](https://github.com/dwyl/english-words/blob/master/words.txt) dictionary file must be placed beside the exe* [`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)) -- cgit v1.2.3 From fdc04ae0c45c48a900eedc8aa08d0021232b3c0a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Tue, 9 Nov 2021 21:26:14 +0100 Subject: Add `extend_selection_line` --- README.md | 1 + plugins/extend_selection_line.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 plugins/extend_selection_line.lua (limited to 'README.md') diff --git a/README.md b/README.md index 5e40895..a521c12 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Plugin | Description [`eval`](plugins/eval.lua?raw=1) | Replaces selected Lua code with its evaluated result [`exec`](plugins/exec.lua?raw=1) | Runs selected text through shell command and replaces with result [`ephemeraldocviews`](plugins/ephemeraldocviews.lua?raw=1) | Preview tabs. Opening a doc will replace the contents of the preview tab. Marks tabs as non-preview on any change. +*[`extend_selection_line`](plugins/extend_selection_line.lua?raw=1)* | When a selection crosses multiple lines, it is drawn to the end of the screen *([screenshot](https://user-images.githubusercontent.com/2798487/140995616-89a20b55-5917-4df8-8a7c-d7c53732fa8b.png))* [`fallbackfonts`](https://github.com/takase1121/lite-fallback-fonts)* | Adds support for fallback fonts *([gif](https://raw.githubusercontent.com/takase1121/lite-fallback-fonts/master/assets/Iw18fI57J0.gif))* [`fontconfig`](plugins/fontconfig.lua?raw=1) | Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html). [`formatter`](https://github.com/vincens2005/lite-formatters)* | formatters for various languages diff --git a/plugins/extend_selection_line.lua b/plugins/extend_selection_line.lua new file mode 100644 index 0000000..a780fe0 --- /dev/null +++ b/plugins/extend_selection_line.lua @@ -0,0 +1,19 @@ +-- mod-version:2 -- lite-xl 2.0 +local DocView = require "core.docview" +local style = require "core.style" + +local draw_line_body = DocView.draw_line_body +function DocView:draw_line_body(idx, x, y, ...) + local lh = self:get_line_height() + for _, line1, _, line2, _ in self.doc:get_selections(true) do + if idx >= line1 and idx < line2 and line1 ~= line2 then + -- draw selection from the end of the line to the end of the available space + local x1 = x + self:get_col_x_offset(idx, #self.doc.lines[idx]) + local x2 = x + self.scroll.x + self.size.x + if x2 > x1 then + renderer.draw_rect(x1, y, x2 - x1, lh, style.selection) + end + end + end + draw_line_body(self, idx, x, y, ...) +end -- cgit v1.2.3 From 333388602d6be6a967d07f0324bc8cefb8351a17 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Fri, 19 Nov 2021 19:15:50 +0100 Subject: Add `indent_convert` --- README.md | 1 + plugins/indent_convert.lua | 100 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 plugins/indent_convert.lua (limited to 'README.md') diff --git a/README.md b/README.md index 6647e2a..c304cb2 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Plugin | Description [`hidelinenumbers`](plugins/hidelinenumbers.lua?raw=1) | Hides the line numbers on the left of documents *([screenshot](https://user-images.githubusercontent.com/3920290/81692043-b8b19c00-9455-11ea-8d74-ad99be4b9c5f.png))* [`hidestatus`](plugins/hidestatus.lua?raw=1) | Hides the status bar at the bottom of the window ~~[`inanimate`](plugins/inanimate.lua?raw=1)~~ | Integrated in lite-xl using `config.transitions = false` ~~Disables all transition animations~~ +*[`indent_convert`](plugins/indent_convert.lua?raw=1)* | Convert between tabs and spaces indentation *[`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 diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua new file mode 100644 index 0000000..103f271 --- /dev/null +++ b/plugins/indent_convert.lua @@ -0,0 +1,100 @@ +-- mod-version:2 -- lite-xl 2.0 +local core = require "core" +local config = require "core.config" +local command = require "core.command" + +config.plugins.indent_convert = { + update_indent_type = true -- set to false to avoid updating the document indent type +} + +-- To replace N spaces with tabs, we match the last N spaces before the start of +-- the actual code and replace them with a tab. +-- We repeat this until we can't find any more spaces before the code. +-- The problem we encounter with this method is that if we have less than N +-- remaining spaces, those will end up at the start of the line. +-- Eg: +-- int main() { +-- __printf("Hello world\n"); +-- ___return 0; +-- } +-- +-- Becomes +-- int main() { +-- #printf("Hello world\n"); +-- _#return 0; +-- } +-- +-- Instead of +-- int main() { +-- #printf("Hello world\n"); +-- #_return 0; +-- } +-- With regex we could do something like +-- `regex.gsub("(^(?: {2})*)(?: {2})", "\\1\t")` +-- but the implementation of `regex.gsub` is very slow. +-- +-- The workaround is to find the longest possible repetition of N*X spaces and +-- use that information to replace the longest repetition of spaces starting +-- from the beginning of the line, then the second longest... +local function spaces_replacer(text) + local spaces = string.rep(" ", config.indent_size) + local total = 0 + local n + local reps = 0 + -- find the longest repetition of indent_size*spaces + repeat + reps = reps + 1 + local s, _ = string.find(text, "%f[^\0\n]"..string.rep(spaces, reps)) + until not s + reps = reps - 1 + while reps > 0 do + text, n = string.gsub(text, + "(%f[^\0\n])("..string.rep(spaces, reps)..")", + "%1"..string.rep("\t", reps)) + total = total + n + reps = reps - 1 + end + return text, total +end + +local function tabs_replacer(text) + local spaces = string.rep(" ", config.indent_size) + local total = 0 + local n + -- replace the last tab before the text until there aren't anymore + repeat + text, n = string.gsub(text, "(%f[^\0\n]\t*)(\t)", "%1"..spaces) + total = total + n + until n == 0 + return text, total +end + +local function tabs_to_spaces() + local doc = core.active_view.doc + doc:replace(tabs_replacer) + if config.plugins.indent_convert.update_indent_type then + doc.indent_info = { + type = "soft", + size = config.indent_size, + confirmed = true + } + end +end + +local function spaces_to_tabs() + local doc = core.active_view.doc + doc:replace(spaces_replacer) + if config.plugins.indent_convert.update_indent_type then + doc.indent_info = { + type = "hard", + size = config.indent_size, + confirmed = true + } + end +end + +command.add("core.docview", { + ["indent-convert:tabs-to-spaces"] = tabs_to_spaces, + ["indent-convert:spaces-to-tabs"] = spaces_to_tabs + } +) -- cgit v1.2.3 From 8db94abfd4a93cb87772d5d9ebaf0a773d637879 Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Tue, 23 Nov 2021 12:33:51 +0900 Subject: Update Readme --- README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'README.md') diff --git a/README.md b/README.md index 6647e2a..024a439 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Plugin | Description [`language_java`](plugins/language_java.lua?raw=1) | Syntax for the [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) programming language [`language_jiyu`](plugins/language_jiyu.lua?raw=1) | Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language [`language_jsx`](plugins/language_jsx.lua?raw=1) | Syntax for the [JSX](https://reactjs.org/docs/introducing-jsx.html) language for the React framework in JavaScript +[`language_julia`](plugins/language_julia.lua?raw=1) | Syntax for the [Julia](https://julialang.org/) programming language [`language_ksy`](https://raw.githubusercontent.com/whiteh0le/lite-plugins/main/plugins/language_ksy.lua?raw=1) | Syntax for [Kaitai](http://kaitai.io/) struct files [`language_liquid`](plugins/language_liquid.lua?raw=1) | Syntax for [Liquid](https://shopify.github.io/liquid/) templating language [`language_lobster`](plugins/language_lobster.lua?raw=1) | Syntax for [Lobster](https://strlen.com/lobster/) programming language -- cgit v1.2.3 From 5426d76142d742fa0419f404e36af62e3a3236b9 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 23 Nov 2021 18:18:05 -0500 Subject: Commit on behalf of @mart-on-windows. --- README.md | 1 + plugins/opacity.lua | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 plugins/opacity.lua (limited to 'README.md') diff --git a/README.md b/README.md index 1f5f35f..970cb36 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ Plugin | Description [`motiontrail`](plugins/motiontrail.lua?raw=1) | Adds a motion-trail to the caret *([screenshot](https://user-images.githubusercontent.com/3920290/83256814-085ccb00-a1ab-11ea-9e35-e6633cbed1a9.gif))* ~~[`nagbar`](https://github.com/takase1121/lite-nagbar)*~~ | integrated in lite-xl ~~consistent and _beautiful_ confirmation dialogs for lite and lite-xl *([gif](https://raw.githubusercontent.com/takase1121/lite-nagbar/master/assets/preview.gif))*~~ [`navigate`](plugins/navigate.lua?raw=1) | Allows moving back and forward between document positions, reducing the amount of scrolling +[`opacity`](plugins/opacity.lua?raw=1) | Change the opaqueness/transparency of `lite-xl` using shift+mousewheel or a command. [`open_ext`](plugins/open_ext.lua?raw=1) | Automatically prompts you if you tried to open a binary file in the editor [`openfilelocation`](plugins/openfilelocation.lua?raw=1) | Opens the parent directory of the current file in the file manager [`openselected`](plugins/openselected.lua?raw=1) | Opens the selected filename or url diff --git a/plugins/opacity.lua b/plugins/opacity.lua new file mode 100644 index 0000000..8dd0d9a --- /dev/null +++ b/plugins/opacity.lua @@ -0,0 +1,62 @@ +-- mod-version:2 -- lite-xl 2.0 +local common = require "core.common" +local command = require "core.command" +local keymap = require "core.keymap" +local RootView = require "core.rootview" + +local opacity_on = true +local use_mousewheel = true +local opacity_steps = 0.05 +local default_opacity = 1 +local current_opacity = default_opacity + +local function set_opacity(opacity) + if not opacity_on then opacity_on = true end + current_opacity = common.clamp(opacity, 0.2, 1) + system.set_window_opacity(current_opacity) +end + +local on_mouse_wheel = RootView.on_mouse_wheel + +function RootView:on_mouse_wheel(d, ...) + if keymap.modkeys["shift"] and use_mousewheel then + if d < 0 then command.perform "opacity:decrease" end + if d > 0 then command.perform "opacity:increase" end + else + return on_mouse_wheel(self, d, ...) + end +end + +local function tog_opacity() + opacity_on = not opacity_on + if opacity_on then + system.set_window_opacity(current_opacity) + else + system.set_window_opacity(default_opacity) + end +end + +local function res_opacity() + set_opacity(default_opacity) +end + +local function inc_opacity() + set_opacity(current_opacity + opacity_steps) +end + +local function dec_opacity() + set_opacity(current_opacity - opacity_steps) +end + +command.add(nil, { + ["opacity:toggle" ] = function() tog_opacity() end, + ["opacity:reset" ] = function() res_opacity() end, + ["opacity:decrease"] = function() dec_opacity() end, + ["opacity:increase"] = function() inc_opacity() end, + ["opacity:toggle mouse wheel use"] = function() use_mousewheel = not use_mousewheel end, +}) + +keymap.add { + ["shift+f11"] = "opacity:toggle", + ["ctrl+f11"] = "opacity:toggle mouse wheel use", +} -- cgit v1.2.3 From 25b5a059bfd3858a2c5d09873451155beafd5903 Mon Sep 17 00:00:00 2001 From: Nightwing Date: Mon, 29 Nov 2021 11:54:07 +0900 Subject: Added Initial scala support --- README.md | 1 + plugins/language_scala.lua | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 plugins/language_scala.lua (limited to 'README.md') diff --git a/README.md b/README.md index a49c21c..779d1c0 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Plugin | Description [`language_rust`](plugins/language_rust.lua?raw=1) | Syntax for the [Rust](https://rust-lang.org/) programming language [`language_ruby`](plugins/language_ruby.lua?raw=1) | Syntax for the [Ruby](https://www.ruby-lang.org/) programming language [`language sass`](plugins/language_sass.lua?raw=1) | Syntax for the [Sass](https://sass-lang.com/) CSS preprocessor +[`language scala`](plugins/language_scala.lua?raw=1) | Syntax for the [Scala](https://scala-lang.org/) programming language [`language_sh`](plugins/language_sh.lua?raw=1) | Syntax for shell scripting language [`language_ssh_config`](plugins/language_ssh_config.lua?raw=1) | Syntax for ssh & sshd config files [`language_tcl`](plugins/language_tcl.lua?raw=1) | Syntax for the [Tcl](https://www.tcl.tk/) programming language diff --git a/plugins/language_scala.lua b/plugins/language_scala.lua new file mode 100644 index 0000000..aa03e28 --- /dev/null +++ b/plugins/language_scala.lua @@ -0,0 +1,80 @@ +-- mod-version:2 -- lite-xl 2.0 +local syntax = require "core.syntax" + +syntax.add { + name = "Scala", + files = { "%.sc$", "%.scala$" }, + comment = "//", + patterns = { + { pattern = "//.-\n", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '[ruU]?"', '"', '\\' }, type = "string" }, + { pattern = { "[ruU]?'", "'", '\\' }, type = "string" }, + { pattern = "0x[%da-fA-F]+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*", type = "number" }, + { pattern = "-?%.?%d+", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = '[%a_][%w_]*"""*[%a_][%w_]*"""', type = "string" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "[%a_][%w_]*", type = "symbol" }, + }, + symbols = { + ["abstract"] = "keyword", + ["case"] = "keyword", + ["catch"] = "keyword", + ["class"] = "keyword", + ["finally"] = "keyword", + ["final"] = "keyword", + ["do"] = "keyword", + ["extends"] = "keyword", + ["forSome"] = "keyword", + ["implicit"] = "keyword", + ["lazy"] = "keyword", + ["match"] = "keyword", + ["new"] = "keyword", + ["override"] = "keyword", + ["package"] = "keyword", + ["throw"] = "keyword", + ["trait"] = "keyword", + ["type"] = "keyword", + ["var"] = "keyword", + ["val"] = "keyword", + ["println"] = "keyword", + ["return"] = "keyword", + ["for"] = "keyword", + ["Try"] = "keyword", + ["def"] = "keyword", + ["while"] = "keyword", + ["with"] = "keyword", + ["if"] = "keyword", + ["else"] = "keyword", + ["import"] = "keyword", + ["object"] = "keyword", + ["yield"] = "keyword", + + ["private"] = "keyword2", + ["protected"] = "keyword2", + ["sealed"] = "keyword2", + ["super"] = "keyword2", + ["this"] = "keyword2", + ["Byte"] = "keyword2", + ["Short"] = "keyword2", + ["Int"] = "keyword2", + ["Long"] = "keyword2", + ["Float"] = "keyword2", + ["Double"] = "keyword2", + ["Char"] = "keyword2", + ["String"] = "keyword2", + ["List"] = "keyword2", + ["Array"] = "keyword2", + ["Boolean"] = "keyword2", + + ["Null"] = "literal", + ["Any"] = "literal", + ["AnyRef"] = "literal", + ["Nothing"] = "literal", + ["Unit"] = "literal", + ["true"] = "literal", + ["false"] = "literal", + } +} -- cgit v1.2.3 From fe42f455405f02a60319ca7056ba405080a3e640 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 1 Dec 2021 00:23:14 +0100 Subject: Add `force_syntax` --- README.md | 1 + plugins/force_syntax.lua | 132 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 plugins/force_syntax.lua (limited to 'README.md') diff --git a/README.md b/README.md index 6647e2a..dbb71f2 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Plugin | Description [`ephemeraldocviews`](plugins/ephemeraldocviews.lua?raw=1) | Preview tabs. Opening a doc will replace the contents of the preview tab. Marks tabs as non-preview on any change. [`fallbackfonts`](https://github.com/takase1121/lite-fallback-fonts)* | Adds support for fallback fonts *([gif](https://raw.githubusercontent.com/takase1121/lite-fallback-fonts/master/assets/Iw18fI57J0.gif))* [`fontconfig`](plugins/fontconfig.lua?raw=1) | Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html). +*[`force_syntax`](plugins/force_syntax.lua?raw=1)* | Change the syntax used for a file. [`formatter`](https://github.com/vincens2005/lite-formatters)* | formatters for various languages [`ghmarkdown`](plugins/ghmarkdown.lua?raw=1) | Opens a preview of the current markdown file in a browser window *([screenshot](https://user-images.githubusercontent.com/3920290/82754898-f7394600-9dc7-11ea-8278-2305363ed372.png))* *[`gitdiff_highlight`](https://github.com/vincens2005/lite-xl-gitdiff-highlight)** | highlight changed lines from git *([screenshot](https://raw.githubusercontent.com/vincens2005/lite-xl-gitdiff-highlight/master/screenshot.png))* diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua new file mode 100644 index 0000000..be9cbbc --- /dev/null +++ b/plugins/force_syntax.lua @@ -0,0 +1,132 @@ +-- mod-version:2 -- lite-xl 2.0 +local core = require "core" +local Doc = require "core.doc" +local syntax = require "core.syntax" +local command = require "core.command" +local common = require "core.common" +local style = require "core.style" +local StatusView = require "core.statusview" +local DocView = require "core.docview" + +local function doc() + if core.active_view and getmetatable(core.active_view) == DocView then return core.active_view.doc end + if core.last_active_view and getmetatable(core.last_active_view) == DocView then return core.last_active_view.doc end +end + +-- Force plaintext syntax to have a name +local plain_text_syntax = syntax.get("") +plain_text_syntax.name = plain_text_syntax.name or "Plain Text" + +local doc_reset_syntax = Doc.reset_syntax +function Doc:reset_syntax() + local syntax_get = syntax.get + if self.force_syntax then + syntax.get = function() return self.force_syntax end + end + doc_reset_syntax(self) + syntax.get = syntax_get +end + +local function get_syntax_name(s) + if not s then return "Undefined" end + local name = s.name + if not name then + local exts = type(s.files) == "string" and { s.files } or s.files + if exts then + name = table.concat(exts, ", ") + end + end + return name or "Undefined" +end + +local statusview_get_items = StatusView.get_items +function StatusView:get_items() + local left, right = statusview_get_items(self) + + local is_dv = core.active_view and getmetatable(core.active_view) == DocView + if not is_dv then return left, right end + + local syntax_name = get_syntax_name(doc().syntax) + + local ins = { + style.dim, + self.separator2, + style.text, + syntax_name + } + + if syntax_name then + for _,item in pairs(ins) do + table.insert(right, item) + end + end + + return left, right +end + +local function get_syntax_list() + local pt_name = plain_text_syntax.name + if doc().syntax == plain_text_syntax then + pt_name = "Current: "..pt_name + end + local list = { ["Auto detect"] = false, + [pt_name] = plain_text_syntax } + local keylist = { "Auto detect", pt_name } + + for _,s in pairs(syntax.items) do + local name = get_syntax_name(s) + local fullname = name + local i = 1 + while list[fullname] do + i = i + 1 + fullname = name.." ("..i..")" + end + if doc().syntax == s then + fullname = "Current: "..fullname + end + list[fullname] = s + table.insert(keylist, fullname) + end + + return list, keylist +end + +local function sorter(a, b) + -- Compare only syntax name + a = a:gsub("Current: ", "") + b = b:gsub("Current: ", "") + return string.upper(a) < string.upper(b) +end + +local function bias_sorter(a, b) + -- Bias towards Current and Auto detect syntax + if a:match("Current: ") then return true end + if b:match("Current: ") then return false end + if a:match("Auto detect") then return true end + if b:match("Auto detect") then return false end + return sorter(a, b) +end + +command.add("core.docview", { + ["force-syntax:select-file-syntax"] = + function() + core.command_view:enter( + "Set syntax for this file", + function(text, item) -- submit + local list, _ = get_syntax_list() + doc().force_syntax = list[item.text] + doc():reset_syntax() + end, + function(text) -- suggest + local _, keylist = get_syntax_list() + local res = common.fuzzy_match(keylist, text) + -- Force Current and Auto detect syntax to the bottom + -- if the text is empty + table.sort(res, #text == 0 and bias_sorter or sorter) + return res + end, + nil, -- cancel + nil -- validate + ) + end +}) -- cgit v1.2.3