Skip to content

Commit 18e2c89

Browse files
committed
refactor(autocomplete): remove autocomplete code
1 parent a2d70d8 commit 18e2c89

File tree

5 files changed

+16
-173
lines changed

5 files changed

+16
-173
lines changed

lua/cosmic-ui/autocomplete/init.lua

-111
This file was deleted.

lua/cosmic-ui/init.lua

+7-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ local M = {}
33

44
local default_border = 'single'
55
local default_user_opts = {
6-
-- border = 'rounded',
7-
autocomplete = false,
6+
border = default_border,
87
lsp_signature = {
98
bind = true, -- This is mandatory, otherwise border config won't get registered.
109
handler_opts = {
@@ -38,13 +37,13 @@ local default_user_opts = {
3837
hover = {
3938
handler = vim.lsp.handlers.hover,
4039
float = {
41-
border = '',
40+
border = default_border,
4241
},
4342
},
4443
signature_help = {
4544
handler = vim.lsp.handlers.signature_help,
4645
float = {
47-
border = '',
46+
border = default_border,
4847
},
4948
},
5049
rename = {
@@ -83,16 +82,6 @@ M.setup = function(user_opts)
8382
-- set up hover
8483
require('cosmic-ui.hover').init(user_opts.hover)
8584
end
86-
87-
if type(user_opts.autocomplete) == 'table' then
88-
M.setup_autocomplete(user_opts.autocomplete)
89-
end
90-
end
91-
92-
M.setup_autocomplete = function(provider_opts)
93-
-- @TODO: should be pulled from options set in .setup
94-
provider_opts = utils.merge(_G.CosmicUI_user_opts.autocomplete or {}, provider_opts)
95-
require('cosmic-ui.autocomplete').init(provider_opts)
9685
end
9786

9887
M.rename = function(popup_opts, opts)
@@ -110,4 +99,8 @@ M.range_code_actions = function(opts)
11099
M.code_actions(opts)
111100
end
112101

102+
M.get_border = function()
103+
return _G.CosmicUI_user_opts.border
104+
end
105+
113106
return M

lua/cosmic-ui/rename/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ local function rename(popup_opts, opts)
4343
}
4444

4545
opts = utils.merge(default_opts, opts or {})
46-
popup_opts = utils.merge(default_popup_opts, popup_opts or {})
46+
popup_opts = utils.merge(default_popup_opts, _G.CosmicUI_user_opts.code_actions.popup_opts or {}, popup_opts or {})
4747
local input = Input(popup_opts, opts)
4848

4949
-- mount/open the component

lua/cosmic-ui/utils.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local M = {}
22

3-
M.merge = function(defaults, opts)
4-
return vim.tbl_deep_extend('force', defaults, opts or {})
3+
M.merge = function(...)
4+
return vim.tbl_deep_extend('force', ...)
55
end
66

77
M.get_relative_path = function(file_path)

readme.md

+6-45
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ Cosmic-UI is a simple wrapper around specific vim functionality. Built in order
1818
- LSP UI
1919
- Signature help
2020
- Hover
21-
- Autocompletion documentation
22-
- Rename floating popup
23-
- Rename file change notification
21+
- Rename floating popup & file change notification
2422
- Code Actions
23+
- Exports values such as the border value set in `.setup` to use elsewhere in your configuration
2524

2625
_Coming soon..._
2726

2827
- Highlighting documentation
29-
- Preview windows?
30-
- LSP definition, references, etc?
3128

3229
## 📷 Screenshots
3330

@@ -44,55 +41,23 @@ _Coming soon..._
4441
```lua
4542
use({
4643
'CosmicNvim/cosmic-ui',
47-
config = function()
48-
require('cosmic-ui').setup()
49-
end,
5044
requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim' },
51-
})
52-
```
53-
54-
To enable `lsp_signature` integration, ensure that `cosmic-ui` initializes _after_ your LSP servers
55-
56-
```lua
57-
use({
58-
'CosmicNvim/cosmic-ui',
5945
config = function()
6046
require('cosmic-ui').setup()
6147
end,
62-
requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim', 'ray-x/lsp_signature.nvim' },
63-
after = 'nvim-lspconfig',
6448
})
6549
```
6650

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

6953
```lua
7054
use({
7155
'CosmicNvim/cosmic-ui',
7256
requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim', 'ray-x/lsp_signature.nvim' },
7357
config = function()
74-
require('cosmic-ui').setup({
75-
autocomplete = {
76-
-- add any nvim-cmp settings you would like to override
77-
}
78-
})
79-
end,
80-
})
81-
```
82-
83-
If you would like to continue to lazy load nvim-cmp, you may alter your setup to the below.
84-
85-
```lua
86-
use({
87-
'hrsh7th/nvim-cmp',
88-
config = function()
89-
require('cosmic-ui').setup_autocomplete({
90-
-- add any nvim-cmp settings you would like to override
91-
})
58+
require('cosmic-ui').setup()
9259
end,
93-
requires = {...},
94-
event = 'InsertEnter',
95-
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
60+
after = 'nvim-lspconfig',
9661
})
9762
```
9863

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

119-
-- autocomplete settings, see `:h cmp-config`
120-
autocomplete = false,
121-
12284
-- see h: vim.diagnostic.config
12385
-- `false` to disable
12486
diagnostic = {
@@ -174,7 +136,6 @@ You may override any of the settings below by passing a config object to `.setup
174136
-- lsp_signature settings
175137
-- `false` to disable
176138
lsp_signature = {
177-
bind = true,
178139
handler_opts = {
179140
-- override border if desired
180141
border = 'rounded',
@@ -207,7 +168,7 @@ You may override any of the settings below by passing a config object to `.setup
207168
}
208169
```
209170

210-
## Utilities
171+
## Usage
211172

212173
#### Rename
213174

0 commit comments

Comments
 (0)