Skip to content

Commit

Permalink
Move capabilities to separate file, update documentation for ins-<CR>
Browse files Browse the repository at this point in the history
  • Loading branch information
deathbeam committed Feb 22, 2024
1 parent 51ed6ae commit a745928
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ You also probably want to enable `popup` in completeopt to show documentation pr
vim.o.completeopt = 'menuone,noinsert,popup'
```

If you want to disable `<CR>` to accept completion (as with autocomplete its disgustingly annoying) you can do this:
If you want to disable `<CR>` to accept completion (as with autocomplete its very annoying) you can do this:

```lua
-- Disable <CR> to accept (this really should be a mapping, so stupid)
vim.keymap.set("i", "<CR>", function()
return vim.fn.pumvisible() ~= 0 and "<Esc>o" or "<CR>"
return vim.fn.pumvisible() ~= 0 and "<C-e><CR>" or "<CR>"
end, { expr = true, replace_keycodes = true })
```

Expand All @@ -84,7 +83,7 @@ when resolving completion items:
-- Here we grab default Neovim capabilities and extend them with ones we want on top
local capabilities = vim.tbl_deep_extend('force',
vim.lsp.protocol.make_client_capabilities(),
require('autocomplete.buffer').capabilities)
require('autocomplete.capabilities'))

-- Now set capabilities on your LSP servers
require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
Expand Down
17 changes: 0 additions & 17 deletions lua/autocomplete/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,6 @@ M.config = {
debounce_delay = 100,
}

M.capabilities = {
textDocument = {
completion = {
completionItem = {
-- Fetch additional info for completion items
resolveSupport = {
properties = {
'documentation',
'detail',
'additionalTextEdits',
},
},
},
},
},
}

function M.setup(config)
M.config = vim.tbl_deep_extend('force', M.config, config or {})
state.entries.completion = util.entry()
Expand Down
16 changes: 16 additions & 0 deletions lua/autocomplete/capabilities.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
return {
textDocument = {
completion = {
completionItem = {
-- Fetch additional info for completion items
resolveSupport = {
properties = {
'documentation',
'detail',
'additionalTextEdits',
},
},
},
},
},
}

0 comments on commit a745928

Please sign in to comment.