petertriho / cmp-git Goto Github PK
View Code? Open in Web Editor NEWGit source for nvim-cmp
License: MIT License
Git source for nvim-cmp
License: MIT License
After installing via :PlugInstall
Opening neovim version 0.5.1 will give:
E5108: Error executing lua [string ":lua"]:1: module 'cmp-git' not found:
no field package.preload['cmp-git']
no file './cmp-git.lua'
no file '/home/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/cmp-git
.lua'
no file '/usr/local/share/lua/5.1/cmp-git.lua'
no file '/usr/local/share/lua/5.1/cmp-git/init.lua'
no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/cmp-git.lua'
no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/cmp-git/init.lua'
no file './cmp-git.so'
no file '/usr/local/lib/lua/5.1/cmp-git.so'
no file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/cmp-git.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
Press ENTER or type command to continue
I'm getting the below error when trying to complete both issues and MRs. Both users and commits complete fine, but when I use the !
or #
triggers, the below error is thrown.
Error executing vim.schedule lua callback: ...vim/site/pack/packer/start/cmp-git/lua/cmp-git/utils.lua:20: attempt to perform arithmetic on local 'hours' (a nil value)
I've tried running the mentioned function in the nvim console and I do get the expected output.
:lua print(os.time()) // 1636683047
Supporting Gitea instances through tea would be nice.
Hello!
I would like to use this with my companies private gitlab instance, is that possible (or if not, could it the feature be added)? I imagine all it would need is the private url and corresponding token for the instance, so maybe a config sources
table could be added with those keypairs?
Thanks!
Not sure what the best triggers for this could be, maybe just alphanumeric characters?
Simplest solution would be to parse something like git log --pretty=oneline
e196ce684384096291f2376ff407e25443adc64b (HEAD -> main, origin/main, origin/HEAD) fix: remove print call
c034da251a55b78fd8275c4c8950465278bfa3fe fix: `.git` suffix in `remote.origin.url` is optional #15
f5dc8323c429985a31a3811493a6ebbf021e85db feat: add gitlab mentions limit
76b5cd47046bdc4f5f2f0c6ceb607eebb177fb90 doc: add gitlab config
1638051cf3f179df4558c6c074be6174dbc4bdd3 feat: add ability to disable individual features
e0331747f5ca85d802d237a68b0b9af978b4283e fix: remove note about json
11e2f17782e81ff530de40237f3ddd883b5f6b13 fix: incorrect glab mentions api url
1c6e2e804a4532da87d8350f1e8f7c993627ffc7 feat: add glab mentions #2
37ea583c41c7eb918d8264fb520e7485e0af9965 docs: add gitlab
56250fe425af384d284d8a530d5cc41b947539d5 Merge pull request #13 from ner0-m/main
39292001286385b1a0793904adec0642e2e469c7 docs: fix setup #14
893a1a851e48a969b538d5b4616e9193a8673dea Use glab api to retrieve more information and easier handling
b4ba5422c0e1ed24f2da6ac7f23bb68a70219d33 feat: Add support for gitlab issues
af3b9fac89254c8d3f1e9f1a00c8cda4f223436d docs: add `plenary.nvim` as a dependency
59ac720796fbff302657445122d3f1530ec93d81 docs: add git as a dependency
2ae17069c8c6232b0f6751e445174a80d895bd11 docs: add section about triggers
e142b2697b71f5f408f771dd24d080256bd06a3a docs: add link to tjdevries's github profile
7974ea63ef43e158acb3c6f1b85011c2f6a10733 feat: add initial code
2e1c4a17209f25e90c444869b324c62e22edc969 Initial commit
Would be nice to have the option to set filetypes = {"*"} indicating completion on all filetypes
#
triggers pull requests!
triggers merge requestsIt would be nice to be able to control how labels are formatted.
For example, I would like issues to display as:
#12 [open]: Example issue title 1
#14 [closed]: Example issue title 2
Perhaps a format
option could be added to source configurations:
require('cmp_git').setup {
github = {
state = 'all',
format = function(issue)
return string.format('#%d: [%s] %s', issue.number, issue.state, issue.title)
end
}
}
Hi! author of octo.nvim here. I was going to work on a nvim-cmp source for octo (issue/prs and metions) and found out your plugin. I think it would be much better to add support for Octo directly on this source rather than writing a new one. Would you be open to support Octo buffers (filetype: octo
)?
I tried to use your source and got:
Error detected while processing TextChangedI Autocommands for "*":
E5108: Error executing lua ...vim/site/pack/packer/start/cmp-git/lua/cmp_git/utils.lua:104: ...vim/site/pack/packer/start/cmp-git/lua/cmp_git/utils.lua:100: Vim(lcd):E472: Command
failed
stack traceback:
[C]: in function 'error'
...vim/site/pack/packer/start/cmp-git/lua/cmp_git/utils.lua:105: in function 'run_in_cwd'
...vim/site/pack/packer/start/cmp-git/lua/cmp_git/utils.lua:86: in function 'get_git_info'
...im/site/pack/packer/start/cmp-git/lua/cmp_git/source.lua:55: in function 'complete'
.../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:296: in function 'complete'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:295: in function 'complete'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:219: in function 'autoindent'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:314: in function 'callback'
...ite/pack/packer/start/nvim-cmp/lua/cmp/utils/autocmd.lua:31: in function 'emit'
[string ":lua"]:1: in main chunk
For an octo buffer, the cwd
variable in utils.lua:104 is octo://OWNER/REPO/issue
so I guess, special handing of octo buffer names is needed
Private instances of Github Enterprise could also be supported natively.
The code in github.lua would exit immediately if the host is not github.com
.
It would take a relatively small change to make this work as most of the framework would work fine (through the gh
client).
As I can see it you could add a list of known private github urls in the conf and test this as part of the source.
The fallback api endpoints in case gh
is missing would also need to be constructed a bit differently.
The current setup requires nvim-cmp
to be loaded, which complicates lazy-loading and dependency management. Ideally one could implement the same structure as in cmp-buffer, where the setup only sets config options while after/plugin
registers the source. I am happy to open a PR to implement this.
Hello,
in https://github.com/petertriho/cmp-git/blob/main/lua/cmp_git/sources/github.lua#L157 is the table.contains
function used which throws an error than for me:
Error executing lua callback: ...l/share/nvim/lazy/cmp-git/lua/cmp_git/sources/gitlab.lua:60: attempt to call field 'contains' (a nil value)
i dont know if this is a custom function in your setup, but for me it does not work.
I replaced this then with vim.tbl_contains
which works then for me.
Errors are not handled (such as unautheticated and empty results)
Make this configurable
Should be able to use gh repo view --json mentionableUsers
At the moment, gh
supports limit > 100
, curl
method only allows 100 per page
During normal usage of quick files / scripts (not in a Git repo), I keep getting the following warning, which I've just accepted for a very long time:
[cmp-git] [WARN 02:19:24] ...pack/packer/start/cmp-git/lua/cmp_git/sources/github.lua:209: Can't fetch Github issues or pull requests, not a github repository
However, upon closer investigation of the source code, it seems that this GitHub source check can be avoided if we ignore completion inside non-Git repositories.
I'm running neovim 0.5.1 and it seems to think vim.json = nil
and it's causing issues it this line
cmp-git/lua/cmp_git/github.lua
Line 51 in 501f910
attempt to index field 'json' (a nil value)
Is neovim 0.6 a requirement for this plugin? I'm not even sure if vim.json
is a 0.6 thing, just trying to identify what/where the issue is.
See title. Could use something like: https://github.com/swisscom/bitbucket-cli to add support in getting issues from Bitbucket.
At the moment, we can only manually select the git commit, typing out the hash (after :
) does not work
Hi and thanks for your plugin!
I've come across an issue with the Gitlab
mentions completion. It inserts nil
instead of the username
, even if the list of usernames and the documentation show the correct values. This can be fixed by the following change to cmp-git/lua/cmp_git/format.lua
:
diff --git a/lua/cmp_git/format.lua b/lua/cmp_git/format.lua
index a76dc20..2c4aa02 100644
--- a/lua/cmp_git/format.lua
+++ b/lua/cmp_git/format.lua
@@ -104,7 +104,7 @@ local M = {
return string.format("@%s", mention.username)
end,
insertText = function(trigger_char, mention)
- return string.format("@%s", mention.login)
+ return string.format("@%s", mention.username)
end,
filterText = function(trigger_char, mention)
return string.format("%s %s", trigger_char, mention.username)
I'll be happy to open a pull request with the fix.
I haven't used the plugin in a while, but it seems that for some reason it stopped working for me, I don't get any completions anymore. Completions for commits ( :
) work, but not for mentions or issues ( #
and @
).
Given that at least on the surface level it looks like my previous problem ( #47 ), I already checked and confirmed the following:
pwd
is set correctly:CmpStatus
correctly lists git
as a ready sourcegitcommit
:lua print(require("cmp_git.utils").is_git_repo())
reports true
cmp.setup.filetype("gitcommit", {
sources = cmp.config.sources {
{name = "git"},
},
})
require("cmp_git").setup()
With more and more behavior being added, I find myself wanting a way to easily add my own triggers. E.g. ;
displaying commits sorted differently than :
. One symbol only showing open issues the next only showing closed ones and such.
So it would be nice to just have a very easy way to "register" a trigger, get the items I want (PRs, MRs or issues with some config), maybe sort them display them specifically or whatever and hand it to cmp.
From :h 'filetype'
:
When a dot appears in the value then this separates two filetype
names. Example:
/* vim: set filetype=c.doxygen : */ ~
This will use the "c" filetype first, then the "doxygen" filetype.
The current filetype handling seems to be this line:
cmp-git/lua/cmp_git/source.lua
Line 80 in 1961ee4
which just checks the entire filetype against the config. I think the correct behavior would be to split the filetype on .
and check each such filetype against the config. I'm happy to write a PR for this.
I suspect this is not a very well-used feature, and it's hidden in a weird place in the help, so totally understand if you don't want to support this. My use-case is setting ft=markdown.github
from the github CLI so I can have markdown support in that buffer (i.e., I can't just use ft=github
) but don't need to turn on cmp-git
for all markdown files (so I can't just use ft=markdown
).
Hi ๐๐ฟ
Been using this cmp source and really enjoying it. One issue I've had with it though is that I use the conventional commits for my commit messages and often hit :
e.g. feat:
which triggers the commit completion. Which is fine, although even if I wanted to disable or remap the trigger looking through the source code I'd have to basically overwrite the list of trigger actions completely rather than being able to change just one field. So since that is cumbersome, and technically I don't mind the trigger I keep the :
but in repositories with a lot of commits this visibly blocks cmp's character input for like a sec or two which given how frequently I commit is quite frustrating.
I don't know if this is a cmp limitation or something to do with how this plugin fetches commits.
Apologies if this is documented somewhere.
For some reason, I can't get cmp-git
to work with the official github CLI (e.x., for writing issues via gh issue create
). By default, it sets its filetype to markdown. I've tried explicitly setting the filetype (by changing the editor command used by the CLI) to markdown.github
, github
, and gitcommit
. Obviously for the former two I adjusted my config as follows:
require("cmp_git").setup({
filetypes = { "gitcommit", "github" },
})
The filetype was getting properly set, and my cmp-git
works in actual git commit messages.
after updating to latest commit I am facing this issue whenever i type or delete the colon (:)
Error executing vim.schedule lua callback: ...im/site/pack/packer/start/cmp-git/lua/cmp_git/format.lua:141: attempt to index field 'format' (a nil value)
stack traceback:
...im/site/pack/packer/start/cmp-git/lua/cmp_git/format.lua:141: in function 'item'
...te/pack/packer/start/cmp-git/lua/cmp_git/sources/git.lua:126: in function 'cb'
vim/_editor.lua:256: in function <vim/_editor.lua:256>
https://github.com/petertriho/cmp-git/blob/main/lua/cmp_git/utils.lua#L8
I think .git
suffix should be optional
I do not get any completions anymore, not sure what happened.
When running :CmpStatus
, I also noticed that cmp-git is listed two times, one of them always "unused", which might be related?
when in a gitcommit file:
my full config:
cmp.setup.filetype("gitcommit", {
sources = cmp.config.sources {
{name = "git"},
},
})
require("cmp_git").setup()
config.github.issues
and config.github.mentions
to false
disable (add ability to disable sources)Probably not even worth doing as this a breaking change with no value added.
Making this customizable through the config might be worth considering though
TODO:
gitlab
in nameWould it be possible to provide whole commit subject line completions when triggered by "fixup!" or "squash!"?
https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---autosquash
https://github.com/suggestions?mention_suggester=1&repository=cmp-git&user_id=petertriho
Investigate if it is possible to use github's (undocumented?) suggestions api
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.