Skip to content

Commit f57d074

Browse files
committed
fix: make luarocks test work + cleanup
1 parent 8426a4b commit f57d074

File tree

8 files changed

+69
-102
lines changed

8 files changed

+69
-102
lines changed

.busted

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
return {
2+
_all = {
3+
coverage = false,
4+
lpath = "lua/?.lua;lua/?/init.lua",
5+
lua = "nlua",
6+
},
7+
default = {
8+
verbose = true,
9+
},
10+
tests = {
11+
verbose = true,
12+
},
13+
}

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.lua]
2+
indent_style = space
3+
indent_size = 2

README.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
11
# Phoenix
22

3-
A blazing-fast asynchronous in-process server providing word and path completion.
3+
A blazing-fast in-process server providing word and path completion.
44

5-
## How fast it is ?
5+
## Demo
66

7-
It enables smooth word completion in nearly 10,000 lines of text and provides
8-
instant completion in projects with thousands of files.
7+
Smooth word completion from nearly 10,000 lines of text and instant path completion in projects with thousands of files.
98

109
![Image](https://github.com/user-attachments/assets/ec81041b-7f37-4613-ad91-419a76ee2eeb)
1110

12-
([auto completion from my neovim config](https://github.com/glepnir/nvim/blob/main/lua/internal/completion.lua))
11+
Words are stored in a [Trie](https://wikipedia.org/wiki/Trie), additionally, they are weighted in frequency and last time used. Low frequency words are cleaned up periodically to speed the process up even more.
1312

14-
In the Phoenix framework, a Trie tree is used to store words, ensuring that the
15-
completion results can be obtained in O(L) time (L is the length of the word).
16-
Additionally, the weight of each word is calculated based on its usage frequency
17-
and last usage time, and low-frequency words are asynchronously cleaned up periodically
18-
to ensure that the desired results can be obtained quickly with each input.
19-
20-
For path completion, Phoenix uses an LRU (Least Recently Used) cache to handle
21-
the results, and the completion results can be obtained in O(1) time. Meanwhile,
22-
the cache is cleaned up based on a set time period to ensure that the directory
23-
status is kept synchronized.
13+
Path completion is done in a similar fashion.
2414

2515
## Usage
2616

2717
**Require neovim nightly**
2818

29-
```lua
30-
require('phoenix').setup()
31-
```
19+
You have to setup your completion to use the fake `phoenix` language server. ([Example using vim.lsp.completion](https://github.com/glepnir/nvim/blob/main/lua/internal/completion.lua)).
3220

33-
default config and custom in `vim.g.phoenix` option table.
21+
Options are configured via `vim.g.phoenix`.
3422

35-
```
23+
```lua
3624
{
3725
filetypes = { '*' },
38-
-- Dictionary related settings
26+
27+
-- Internal cache settings
3928
dict = {
4029
-- Maximum number of words to store in the dictionary
4130
-- Higher values consume more memory but provide better completions
@@ -44,6 +33,7 @@ default config and custom in `vim.g.phoenix` option table.
4433
-- Minimum word length to be considered for completion
4534
-- Shorter words may create noise in completions
4635
min_word_length = 2,
36+
4737
-- Time factor weight for sorting completions (0-1)
4838
-- Higher values favor recently used items more strongly
4939
recency_weight = 0.3,
@@ -56,9 +46,11 @@ default config and custom in `vim.g.phoenix` option table.
5646
-- Performance related settings
5747
scan = {
5848
cache_ttl = 5000,
49+
5950
-- Number of items to process in each batch
6051
-- Higher values improve speed but may cause stuttering
6152
batch_size = 1000,
53+
6254
-- Ignored the file or dictionary which matched the pattern
6355
ignore_patterns = {},
6456

doc/phoenix.txt

Lines changed: 0 additions & 67 deletions
This file was deleted.

lua/phoenix/init.lua

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,7 @@ function server.create()
597597
end
598598
end
599599

600-
local function setup()
601-
vim.api.nvim_create_autocmd('FileType', {
602-
pattern = cfg.filetypes,
603-
callback = function()
604-
vim.lsp.start({
605-
name = 'phoenix',
606-
cmd = server.create(),
607-
root_dir = vim.uv.cwd(),
608-
})
609-
end,
610-
})
611-
end
612-
613-
return { setup = setup }
600+
return {
601+
server = server,
602+
config = cfg,
603+
}

phoenix.nvim-scm-1.rockspec

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
rockspec_format = '3.0'
2+
package = 'phoenix.nvim'
3+
version = 'scm-1'
4+
5+
test_dependencies = {
6+
'lua >= 5.1',
7+
'nlua',
8+
}
9+
10+
source = {
11+
url = 'git://github.com/nvimdev/' .. package,
12+
}
13+
14+
build = {
15+
type = 'builtin',
16+
}

plugin/phoenix.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
local phoenix = require('phoenix')
2+
3+
vim.api.nvim_create_autocmd('FileType', {
4+
pattern = phoenix.config.filetypes,
5+
callback = function()
6+
vim.lsp.start({
7+
name = 'phoenix',
8+
cmd = phoenix.server.create(),
9+
---@diagnostic disable-next-line: undefined-field
10+
root_dir = vim.uv.cwd(),
11+
})
12+
end,
13+
})

spec/plugin_spec.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local same = assert.are.same
2+
3+
describe('example test', function()
4+
it('works', function()
5+
same(1 + 1, 2)
6+
end)
7+
end)

0 commit comments

Comments
 (0)