Comments (9)
Thanks, @davidgranstrom! Didn't think about that approach. It helps a lot, and it also made me take a critical look at what exactly I stuffed into my nvim-cmp sources :-)
from scnvim.
It has to be up to the snippet framework since scnvim does not load the snippets.
There is an API function to get the path of a generated asset without loading anything, maybe that can be used for lazy loading depending on how the snippet engine works?
local asset_path = require('scnvim.path').get_asset 'snippets'
I have started sketching on a notification system that might be useful for these types of tasks, not sure if it will make it into #153, but I imagine it to work something like this:
--- in init.vim
local notification = require 'scnvim.notification'
notification.add_subscriber('sclang_started', function(object)
-- executed once sclang has been started
vim.cmd [[ SCNvimGenerateAssets ]]
end)
from scnvim.
Good, good, will start looking into how the other frameworks do the lazy loading and see if this can be used fon sclang.
from scnvim.
Thinking about this some more, you could probably set up an autocmd for this (e.g. FileType) and load the snippets like you do now but instead the first time entering a supercollider
buffer
from scnvim.
That works indeed! However, I find nvim very sluggish in general when using the snippets, so I would like to find some other way of loading them. Homework for some other time...
from scnvim.
because I lazy-load both scnvim
and luasnip
, to prevent erroring only when one of them is loaded, I use something like this
vim.api.nvim_create_autocmd("InsertEnter", {
pattern = "*.scd, *.sc, *.sc_help, *.quark",
group = some_group_id,
callback = function()
require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets())
end,
once = true,
})
Note the once
flag!
This does add a lag between 1-2 seconds the very first time I InsertEnter
in scnvim
but it does the job
Perhaps luasnip
has some lazier method that replicates add_snippets
method?
from scnvim.
Thanks, @ranjithshegde! This works really well now on my system. There may be some small lag when typing, but not too much. I might have to look into how many items nvim-cmp populates the menu with, seems to be connected somehow...
from scnvim.
Since the auto generated snippet file is quite large I would imagine that limiting the entries for nvim-cmp would help. (I have it configured to only auto complete after typing 3 characters and that seem to work pretty well also for language servers where I've experienced similar lag, not sure how it works with snippets since I'm not using that for the moment)
from scnvim.
because I lazy-load both
scnvim
andluasnip
, to prevent erroring only when one of them is loaded, I use something like thisvim.api.nvim_create_autocmd("InsertEnter", { pattern = "*.scd, *.sc, *.sc_help, *.quark", group = some_group_id, callback = function() require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets()) end, once = true, })Note the
once
flag! This does add a lag between 1-2 seconds the very first time IInsertEnter
inscnvim
but it does the jobPerhaps
luasnip
has some lazier method that replicatesadd_snippets
method?
Suddenly this approach stopped working for me, but was easily fixable by replacing
pattern = "*.scd, *.sc, *.sc_help, *.quark",
with
pattern = { "*.scd", "*.sc", "*.sc_help", "*.quark"},
from scnvim.
Related Issues (20)
- [BUG] Error If postwindow float in not enable HOT 2
- [FR]: More documentation on how to use it: describe how you can run code HOT 5
- [FR]: Implement Arrays in SCNvimJSON:stringify HOT 3
- [BUG] Error executing vim.schedule lua callback: […] Unrecognized handler HOT 2
- [BUG] Toggle post window leaves empty buffers HOT 6
- [BUG] scnvim foobar HOT 5
- [BUG] Syntax highlighting is not consistent with multiline strings HOT 2
- [BUG] s.meter only works after recompiling class library HOT 3
- [BUG] Editor commands do not work HOT 2
- [BUG] Error using pandoc on Linux HOT 1
- [BUG] Reloading a session with scnvim using Startify causes errors HOT 1
- [BUG] need help with tags file on wsl HOT 6
- [BUG] SCNvim crashes out of Neovim from too fast input. HOT 15
- [BUG] HOT 1
- [BUG] Return cached results from help.get_docmap
- [BUG] ERROR: Class not defined, ERROR: Could not iterate on directory, HOT 2
- [BUG] UGen Arguments not visible HOT 2
- [FR]: Send commands to remote sclang HOT 2
- [BUG] Signature hint window disappears in insert mode HOT 9
- [BUG] error message when typing (Done.freeSelf, \gate.kr(1)) in a SynthDef HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scnvim.