nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
3.04k stars 134 forks source link

completion-nvim support #5

Closed ranjithshegde closed 3 years ago

ranjithshegde commented 3 years ago

Does this feature exist in Emacs orgmode?

If answer to first question is "No", elaborate on how this feature is valuable and what problem does it solve. Using completion-nvim for autocompletion. Either by add this as a custom completion sources (similar to vimtex) or a direct integration.

If you could add steps to do so as a wiki or in README Thanks ...

kristijanhusak commented 3 years ago

Support for completion-nvim is added. Check https://github.com/kristijanhusak/orgmode.nvim#completion section.

Only limitation with completion-nvim is that it's not able to complete multiple tags. For example, if you have tags WORK and OFFICE, and having this content:

* TODO Some task :

It will suggest both tags in this case, but once you select one of them:

 TODO Some task :WORK:

It is no longer possible to complete any more tags because completion-nvim uses \k regex, which reads iskeyword. I added : to it in order to be able to complete tags and properties, but this breaks the multiple tags. Workaround is just to use omnifunc in these cases, because that properly autocompletes multiple tags.

ranjithshegde commented 3 years ago

@kristijanhusak Thank you For the problem you described, perhaps I could add omni as a custom source, chain it along for 'org' and enable auto_changing of the sources

kristijanhusak commented 3 years ago

@ranjithshegde yeah, something like that could work, I haven't tried it though.

kristijanhusak commented 3 years ago

@ranjithshegde Thanks, I just gave omni mode a try, and it works great. There's no need to add any special support for completion-nvim, just use omni mode:

vim.g.completion_chain_complete_list = {
  org = {
    { mode = 'omni'},
  },
}
ranjithshegde commented 3 years ago

@kristijanhusak I kind of prefer it to be more 'auto' than omni. meaning, without trigger characters omni only populates pumvisible with options beginning from the letter. For example it does not complete DEADLINE after : but only after :D

For now I have made a custom source from myself using require('orgmode.org.autocompletion').omni($) with appending to iskeyword with :,#,+ as you did in the relevant commit

kristijanhusak commented 3 years ago

@ranjithshegde you're right, adding those to iskeyword is necessary to make it work. I'll update the readme. Thanks.

physicophilic commented 3 years ago

Thanks @kristijanhusak. Earlier I was using completion-nvim only for LSPs so had to attach it to the buffer! Adding this works!

autocmd FileType org setlocal iskeyword+=:,#,+ |
            \ lua require'completion'.on_attach()