Skip to content

Commit

Permalink
refactor(autocomplete): remove autocomplete code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleong committed Dec 14, 2021
1 parent a2d70d8 commit 18e2c89
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 173 deletions.
111 changes: 0 additions & 111 deletions lua/cosmic-ui/autocomplete/init.lua

This file was deleted.

21 changes: 7 additions & 14 deletions lua/cosmic-ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ local M = {}

local default_border = 'single'
local default_user_opts = {
-- border = 'rounded',
autocomplete = false,
border = default_border,
lsp_signature = {
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
Expand Down Expand Up @@ -38,13 +37,13 @@ local default_user_opts = {
hover = {
handler = vim.lsp.handlers.hover,
float = {
border = '',
border = default_border,
},
},
signature_help = {
handler = vim.lsp.handlers.signature_help,
float = {
border = '',
border = default_border,
},
},
rename = {
Expand Down Expand Up @@ -83,16 +82,6 @@ M.setup = function(user_opts)
-- set up hover
require('cosmic-ui.hover').init(user_opts.hover)
end

if type(user_opts.autocomplete) == 'table' then
M.setup_autocomplete(user_opts.autocomplete)
end
end

M.setup_autocomplete = function(provider_opts)
-- @TODO: should be pulled from options set in .setup
provider_opts = utils.merge(_G.CosmicUI_user_opts.autocomplete or {}, provider_opts)
require('cosmic-ui.autocomplete').init(provider_opts)
end

M.rename = function(popup_opts, opts)
Expand All @@ -110,4 +99,8 @@ M.range_code_actions = function(opts)
M.code_actions(opts)
end

M.get_border = function()
return _G.CosmicUI_user_opts.border
end

return M
2 changes: 1 addition & 1 deletion lua/cosmic-ui/rename/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local function rename(popup_opts, opts)
}

opts = utils.merge(default_opts, opts or {})
popup_opts = utils.merge(default_popup_opts, popup_opts or {})
popup_opts = utils.merge(default_popup_opts, _G.CosmicUI_user_opts.code_actions.popup_opts or {}, popup_opts or {})
local input = Input(popup_opts, opts)

-- mount/open the component
Expand Down
4 changes: 2 additions & 2 deletions lua/cosmic-ui/utils.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {}

M.merge = function(defaults, opts)
return vim.tbl_deep_extend('force', defaults, opts or {})
M.merge = function(...)
return vim.tbl_deep_extend('force', ...)
end

M.get_relative_path = function(file_path)
Expand Down
51 changes: 6 additions & 45 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ Cosmic-UI is a simple wrapper around specific vim functionality. Built in order
- LSP UI
- Signature help
- Hover
- Autocompletion documentation
- Rename floating popup
- Rename file change notification
- Rename floating popup & file change notification
- Code Actions
- Exports values such as the border value set in `.setup` to use elsewhere in your configuration

_Coming soon..._

- Highlighting documentation
- Preview windows?
- LSP definition, references, etc?

## 📷 Screenshots

Expand All @@ -44,55 +41,23 @@ _Coming soon..._
```lua
use({
'CosmicNvim/cosmic-ui',
config = function()
require('cosmic-ui').setup()
end,
requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim' },
})
```

To enable `lsp_signature` integration, ensure that `cosmic-ui` initializes _after_ your LSP servers

```lua
use({
'CosmicNvim/cosmic-ui',
config = function()
require('cosmic-ui').setup()
end,
requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim', 'ray-x/lsp_signature.nvim' },
after = 'nvim-lspconfig',
})
```

Autocomplete functionality is disabled by default, if you would like to set it up. Ensure that Cosmic-UI is also initialized after nvim-cmp.
To enable `lsp_signature` integration, ensure that `cosmic-ui` initializes _after_ your LSP servers. This is a requirement of `lsp_signature` itself.

```lua
use({
'CosmicNvim/cosmic-ui',
requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim', 'ray-x/lsp_signature.nvim' },
config = function()
require('cosmic-ui').setup({
autocomplete = {
-- add any nvim-cmp settings you would like to override
}
})
end,
})
```

If you would like to continue to lazy load nvim-cmp, you may alter your setup to the below.

```lua
use({
'hrsh7th/nvim-cmp',
config = function()
require('cosmic-ui').setup_autocomplete({
-- add any nvim-cmp settings you would like to override
})
require('cosmic-ui').setup()
end,
requires = {...},
event = 'InsertEnter',
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
after = 'nvim-lspconfig',
})
```

Expand All @@ -116,9 +81,6 @@ You may override any of the settings below by passing a config object to `.setup
hint = '',
},

-- autocomplete settings, see `:h cmp-config`
autocomplete = false,

-- see h: vim.diagnostic.config
-- `false` to disable
diagnostic = {
Expand Down Expand Up @@ -174,7 +136,6 @@ You may override any of the settings below by passing a config object to `.setup
-- lsp_signature settings
-- `false` to disable
lsp_signature = {
bind = true,
handler_opts = {
-- override border if desired
border = 'rounded',
Expand Down Expand Up @@ -207,7 +168,7 @@ You may override any of the settings below by passing a config object to `.setup
}
```

## Utilities
## Usage

#### Rename

Expand Down

0 comments on commit 18e2c89

Please sign in to comment.