nvim-cmp source for treesitter nodes. Using all treesitter highlight nodes as completion candicates. LRU cache is used to improve performance.
require'cmp'.setup {
sources = {
{ name = 'treesitter' }
}
}
cmp source for treesitter
License: GNU General Public License v3.0
Using treesitter completions with this plugins makes the whole insert mode quite laggy. Can anything be done about that or is it unavoidable?
Hi,
I keep getting this error:
E5108: Error executing lua .../packer/start/cmp-treesitter/lua/cmp_treesitter/init.lua:51: bad argument #1 to 'ipairs' (table expected, got nil)```
Thank you for looking into it.
Regards,
Omar
Maybe add examples on how this is useful. Between all the sources that cmp can have, I can't legitimately tell what this does for me. I love both cmp and treesitter, so I'd love to see if I get benefit from this.
stack traceback:
...rapped-bad218c/share/nvim/runtime/lua/vim/treesitter.lua:28: in function '__index'
...s/start/cmp-treesitter/lua/cmp_treesitter/treesitter.lua:43: in function <...s/start/cmp-treesitter/lua/cmp_treesitter/treesitter.lua:31
>
This appears briefly upon typing in insert mode and typing... I'm not sure how to get more context for what's happening here.
I occasionally will get this error. I've not really found it to be reproducible though:
Error executing vim.schedule lua callback: vim/shared.lua:0: after the second argument: expected table, got nil
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
vim/shared.lua: in function 'tbl_deep_extend'
.../packer/start/cmp-treesitter/lua/cmp_treesitter/init.lua:19: in function 'get_keyword_pattern'
.../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:163: in function 'callback'
.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/cache.lua:36: in function 'get_default_replace_range'
...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:45: in function 'new'
.../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:316: in function ''
vim.lua: in function <vim.lua:0>
Maybe it makes sense to you?
Hi there!
I'm experiencing some strange issue with cmp-treesitter
with [quotes] autopairing:
cmp-treesitter
suggest that quoted node as completion (dunno why TS doesn't cut quotes when collecting nodes ๐คท).This is demonstration:
Is it possible to maybe somehow ask cmp-treesitter
to cut quotes before passing node to cmp
?
Or, maybe, it is possible to somehow ask cmp
(or cmp-treesitter
?) to take closing quote into account (like it does with middle-word/fuzzy completions)?
a. I start comment block
b. I type lua
as start of word-to-be-completed
c. I see -- luacheck: ...
as treesitter completion
d. I select it and I see it inserted one more --
(so there is double commented string, which, by the way, doesn't count as valid luacheck directive).
Here is a demonstration:
So, it seems, in that situation it doesn't even count "left" part of completeion...
Can that things be fixed?
Or it is all on cmp
itself behalf, and cmp-treesitter
have nothing to do here?
async fn run(options: Opt) -> Result<()> {
let (certs, key) = if let (Some(key_path), Some(cert_path)) = (&options.key, &options.cert) {
key_log
let key = fs::read(key_path).context("failed to read private key")?;
let key = if key_path.extension().map_or(false, |x| x == "der") {
rustls::PrivateKey(key)
} else {
let pkcs8 = rustls_pemfile::pkcs8_private_keys(&mut &*key)
.context("malformed PKCS #8 private key")?;
is sample Rust code from quinn (server.rs in examples).
You see that Some(key_path) defines a var you want to complete.
That Some(key_path) get's understood as identifier (See HERE)
let_declaration [62, 4] - [121, 6]
pattern: tuple_pattern [62, 8] - [62, 20]
identifier [62, 9] - [62, 14]
identifier [62, 16] - [62, 19]
value: if_expression [62, 23] - [121, 5]
condition: let_condition [62, 26] - [62, 95]
pattern: tuple_pattern [62, 30] - [62, 63]
tuple_struct_pattern [62, 31] - [62, 45]
type: identifier [62, 31] - [62, 35] << HERE
identifier [62, 36] - [62, 44]
tuple_struct_pattern [62, 47] - [62, 62]
type: identifier [62, 47] - [62, 51]
identifier [62, 52] - [62, 61]
Not all identifiers are declarations.
https://github.com/ms-jpq/coq_nvim also has a treesitter based completion implementation. So there might be yet another trace for joint efforts ?
What I am exactly interested in is
I have uploaded my code here so that you get a feeling how it behaves and how much it saves.
https://github.com/MarcWeber/nvim-cmp-local-identifiers-by-regex-completion-quick-and-dirty
Could you please share what font is being used in the screenshots, especially for those gorgeous italics?
Error detected while processing /home/llyyr/.local/share/nvim/site/pack/packer/start/cmp-treesitter/after/plugin/cmp_treesitter.lua:
E5113: Error while calling lua chunk: /usr/share/nvim/runtime/lua/vim/uri.lua:43: attempt to call upvalue 'tohex' (a nil value)
stack traceback:
/usr/share/nvim/runtime/lua/vim/uri.lua:43: in function </usr/share/nvim/runtime/lua/vim/uri.lua:42>
[C]: in function 'uri_encode'
/usr/share/nvim/runtime/lua/vim/uri.lua:67: in function 'uri_from_fname'
...r/start/cmp-treesitter/lua/cmp_treesitter/treesitter.lua:7: in function <...r/start/cmp-treesitter/lua/cmp_treesitter/treesitter.lua:5>
[C]: in function 'require'
.../packer/start/cmp-treesitter/lua/cmp_treesitter/init.lua:1: in main chunk
[C]: in function 'require'
...ker/start/cmp-treesitter/after/plugin/cmp_treesitter.lua:1: in main chunk
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.