Coder Social home page Coder Social logo

cmp-git's People

Contributors

axieax avatar b0o avatar curs3w4ll avatar daliusd avatar delphinus avatar gitmurf avatar hrsh7th avatar jakubbortlik avatar kbenzie avatar msvechla avatar ner0-m avatar petertriho avatar rileyshahar avatar sledigabel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmp-git's Issues

issue with colon

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>

mention for Gitlab inserts nil instead of username

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.

Bug: do not get completions anymore for issues and mentions

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 source
  • filetype is correctly set to gitcommit
  • :lua print(require("cmp_git.utils").is_git_repo()) reports true
  • [I enabled cmp_git for the lua filetype](I enabled cmp_git for the lua filetype), and the same thing happens here.
  • I am still using the minimal config as before:
cmp.setup.filetype("gitcommit", {
	sources = cmp.config.sources {
		{name = "git"},
	},
})
require("cmp_git").setup()

add after/plugin

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.

Disable if not in git repo

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.

Support for Github Enterprise

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.

vimplug: not able to find cmp-git

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

Custom behaviour for trigger

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.

Use with private Gitlab instance

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!

Problem getting GitLab data

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

Incorrect handling of dot-separated filetypes

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:

return self.filetypes["*"] ~= nil or self.filetypes[vim.bo.filetype] ~= nil

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).

Add better documentation

  • Add explanations of each config value
  • Can set config.github.issues and config.github.mentions to false disable (add ability to disable sources)

Not working through github CLI

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.

Support for Octo.nvim

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

Rename source from `cmp_git` to `git`

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

[bug] commits trigger blocks cmp if there are very many commits in a repository

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.

Support custom label formats

It 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
  }
}

Investigate other sources for @mentions

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

attempt to index field 'json' (a nil value)

I'm running neovim 0.5.1 and it seems to think vim.json = nil and it's causing issues it this line

local ok, parsed = pcall(vim.json.decode, table.concat(result, ""))
and giving me the error 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.

"*" filetype

Would be nice to have the option to set filetypes = {"*"} indicating completion on all filetypes

Bug: not completing at all & two cmp-git sources listed

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:

image

when in any other filetype:
image

my full config:

cmp.setup.filetype("gitcommit", {
	sources = cmp.config.sources {
		{name = "git"},
	},
})
require("cmp_git").setup()

BUG: attempt to call field 'contains' (a nil value)

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.

Add git

  • git hashes
  • conventional commmits
  • branches/refs

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

Handle errors

Errors are not handled (such as unautheticated and empty results)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.