diff --git a/lua/scnvim/commands.lua b/lua/scnvim/commands.lua index 686ea36e..8ccf270c 100644 --- a/lua/scnvim/commands.lua +++ b/lua/scnvim/commands.lua @@ -24,7 +24,7 @@ return function() print('[scnvim] Assets written to ' .. get_cache_dir()) end sclang.generate_assets(on_done) - end, 'Generate syntax highlightning and snippets') + end, 'Generate syntax highlighting and snippets') local options = { nargs = 1, desc = 'Open help for subject' } local open_help = function(tbl) diff --git a/lua/scnvim/config.lua b/lua/scnvim/config.lua index ecc9c03b..012e78fa 100644 --- a/lua/scnvim/config.lua +++ b/lua/scnvim/config.lua @@ -100,7 +100,7 @@ local default = { border = 'single', }, callback = function(id) - vim.api.nvim_win_set_option(id, 'winblend', 10) + vim.api.nvim_set_option_value('winblend', 10, { win = id }) end, }, }, diff --git a/lua/scnvim/editor.lua b/lua/scnvim/editor.lua index 845946ef..30a1afbb 100644 --- a/lua/scnvim/editor.lua +++ b/lua/scnvim/editor.lua @@ -69,6 +69,7 @@ local function flash_region(start, finish) if repeats > 1 then local count = 0 local timer = uv.new_timer() + assert(timer, 'Could not create timer') timer:start( duration, duration, @@ -115,11 +116,12 @@ local function fade_region(start, finish) anchor = lstart > 0 and 'NW' or 'SE', } local id = api.nvim_open_win(buf, false, options) - api.nvim_win_set_option(id, 'winhl', 'Normal:' .. 'SCNvimEval') + api.nvim_set_option_value('winhl', 'Normal:' .. 'SCNvimEval', { win = id }) local timer = uv.new_timer() local rate = 50 local accum = 0 local duration = math.floor(config.editor.highlight.fade.duration) + assert(timer, 'Could not create timer') timer:start( 0, rate, @@ -129,7 +131,7 @@ local function fade_region(start, finish) accum = duration end local value = math.pow(accum / duration, 2.5) - api.nvim_win_set_option(id, 'winblend', math.floor(100 * value)) + api.nvim_set_option_value('winblend', math.floor(100 * value), { win = id }) if accum >= duration then timer:stop() api.nvim_win_close(id, true) diff --git a/lua/scnvim/map.lua b/lua/scnvim/map.lua index 5078f38b..9aa975c5 100644 --- a/lua/scnvim/map.lua +++ b/lua/scnvim/map.lua @@ -66,7 +66,7 @@ local map_expr = function(expr, modes, options) modes = type(modes) == 'string' and { modes } or modes options = options or {} options.silent = options.silent == nil and true or options.silent - options.desc = options.desc or 'sclang: ' .. expr + options.desc = options.desc or ('sclang: ' .. expr) return map(function() require('scnvim.sclang').send(expr, options.silent) end, modes, options) diff --git a/lua/scnvim/sclang.lua b/lua/scnvim/sclang.lua index 0e3f1dfc..51a1d50b 100644 --- a/lua/scnvim/sclang.lua +++ b/lua/scnvim/sclang.lua @@ -231,6 +231,7 @@ function M.stop(_, callback) udp.stop_server() M.send('0.exit', true) local timer = uv.new_timer() + assert(timer, 'Could not create timer') timer:start(1000, 0, function() if M.proc then local ret = M.proc:kill 'sigkill' diff --git a/lua/scnvim/signature.lua b/lua/scnvim/signature.lua index 59c9ff10..2a1fba31 100644 --- a/lua/scnvim/signature.lua +++ b/lua/scnvim/signature.lua @@ -29,7 +29,7 @@ local function extract_objects_helper(str) objects = vim.tbl_map(function(s) return vim.split(s, ',', true) end, objects) - objects = vim.tbl_flatten(objects) + objects = vim.iter(objects):flatten():totable() objects = vim.tbl_map(function(s) -- filter out empty strings (nvim 0.5.1 compatability fix, use -- vim.split(..., {trimempty = true}) for nvim 0.6) diff --git a/scide_scnvim/Classes/SCNvim.sc b/scide_scnvim/Classes/SCNvim.sc index 96b4f80c..34d6c044 100644 --- a/scide_scnvim/Classes/SCNvim.sc +++ b/scide_scnvim/Classes/SCNvim.sc @@ -146,8 +146,14 @@ SCNvim { Class.allClasses.do {arg klass; var className, argList, signature; if (klass.asString.beginsWith("Meta_").not) { + var currClass = klass; + // get methods from superclass for derived classes + // TODO: should traverse entire heirarchy but this produces too many snippets! + while ({currClass.class.methods.isNil}, { + currClass = currClass.superclass; + }); // collect all creation methods - klass.class.methods.do {arg meth; + currClass.class.methods.do {arg meth; var index, snippet; var snippetName; var description; diff --git a/scide_scnvim/Classes/SCNvimDoc/SCNvimDoc.sc b/scide_scnvim/Classes/SCNvimDoc/SCNvimDoc.sc index caad842c..a98060b7 100644 --- a/scide_scnvim/Classes/SCNvimDoc/SCNvimDoc.sc +++ b/scide_scnvim/Classes/SCNvimDoc/SCNvimDoc.sc @@ -234,10 +234,9 @@ SCNvimDocEntry : SCDocEntry { } // overriden to output valid json - prJSONList {|stream, key, v, lastItem| - var delimiter = if(lastItem.notNil and:{lastItem}, "", ","); + prJSONList {|stream, key, v| if (v.isNil) { v = "" }; - stream << "\"" << key << "\": [ " << v.collect{|x|"\""++x.escapeChar(34.asAscii)++"\""}.join(",") << " ]%\n".format(delimiter); + stream << "\"" << key << "\": [ " << v.collect{|x|"\""++x.escapeChar(34.asAscii)++"\""}.join(",") << " ],\n"; } toJSON {|stream, lastItem| @@ -262,28 +261,24 @@ SCNvimDocEntry : SCDocEntry { this.prJSONString(stream, "oldhelp", oldHelp); }; - if (klass.notNil) { - keys = #[ "superclasses", "subclasses", "implementor" ]; + if(klass.notNil) { klass.superclasses !? { - inheritance = inheritance.add(klass.superclasses.collect {|c| + this.prJSONList(stream, "superclasses", klass.superclasses.collect {|c| c.name.asString - }); + }) }; klass.subclasses !? { - inheritance = inheritance.add(klass.subclasses.collect {|c| + this.prJSONList(stream, "subclasses", klass.subclasses.collect {|c| c.name.asString - }); + }) }; implKlass !? { - inheritance = inheritance.add(implKlass.name.asString); - }; - - numItems = inheritance.size - 1; - inheritance.do {|item, i| - this.prJSONList(stream, keys[i], item, i >= numItems); - }; + this.prJSONString(stream, "implementor", implKlass.name.asString); + } }; - stream << "}%\n".format(delimiter); + stream.seek(-2, 1); + + stream << "\n}%\n".format(delimiter); } }