Skip to content

Commit

Permalink
Added dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
atropos112 committed Feb 17, 2025
1 parent 379a972 commit 989d3c4
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 18 deletions.
3 changes: 2 additions & 1 deletion lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"actions-preview.nvim": { "branch": "master", "commit": "9f52a01c374318e91337697ebed51c6fae57f8a4" },
"alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" },
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
"blink-cmp-dictionary": { "branch": "master", "commit": "97c060e0751e95d2a1fbffe2871712bb676092ab" },
"blink-ripgrep.nvim": { "branch": "main", "commit": "519ac7894113f6a7b517b157c26e31fbd58a0de5" },
"blink.cmp": { "branch": "main", "commit": "b6f11a0aa33e601c469a126e3ed6e35208fe3ea3" },
"blink.compat": { "branch": "main", "commit": "b0c87b64f9c669d3bcfaea8a80396fbc16e0fcb5" },
Expand Down Expand Up @@ -65,7 +66,6 @@
"neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" },
"neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" },
"neotest-dotnet": { "branch": "main", "commit": "5a2fa35c3c6a72cfd3fc6a28b3d1af6e68e6c3a8" },
"neotest-go": { "branch": "main", "commit": "92950ad7be2ca02a41abca5c6600ff6ffaf5b5d6" },
"neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" },
"noice.nvim": { "branch": "main", "commit": "cf758e9df66451889aab56613a21b8673f045ec2" },
"none-ls.nvim": { "branch": "main", "commit": "ed8f80849ef1ad31c2f74679fafdef7801091247" },
Expand All @@ -81,6 +81,7 @@
"nvim-dap-repl-highlights": { "branch": "master", "commit": "a7512fc0a0de0c0be8d58983939856dda6f72451" },
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" },
"nvim-ginkgo": { "branch": "main", "commit": "12e1cb60d1254b39dbdffac1e4fcbf8f0afd98da" },
"nvim-lightbulb": { "branch": "master", "commit": "f7f61c47af5bf701b1f4af127bc565ab6491acbf" },
"nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" },
"nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" },
Expand Down
68 changes: 51 additions & 17 deletions lua/atro/plugins/cmp.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local dict_path = os.getenv("HOME") .. "/.local/share/nvim/dict.txt"

---@type LazyPlugin[]
return {
{
Expand All @@ -12,6 +14,20 @@ return {
debug = false,
},
},
{
"Kaiser-Yang/blink-cmp-dictionary",
dependencies = {
"nvim-lua/plenary.nvim",
},
lazy = true,
config = function()
-- If there is no dictionary get it.
if vim.fn.filereadable(dict_path) == 0 or vim.fn.getftime(dict_path) < os.time() - 86400 then
vim.fn.system("wget -q -O " .. dict_path .. " https://raw.githubusercontent.com/dwyl/english-words/refs/heads/master/words_alpha.txt")
LOGGER:with({ dict_path = dict_path }):info("Downloaded dictionary, a one time operation")
end
end,
},
{
"saghen/blink.cmp",
event = { "VeryLazy" },
Expand All @@ -24,10 +40,31 @@ return {
"rcarriga/cmp-dap",
"xzbdmw/colorful-menu.nvim",
"mikavilpas/blink-ripgrep.nvim",
"Kaiser-Yang/blink-cmp-dictionary",
},
version = "*",
config = function()
local is_dap_buffer = require("cmp_dap").is_dap_buffer
local log = LOGGER:with({ phase = "CMP" })

local sql_filetypes = { mysql = true, sql = true }

-- Computing sources here rather than later so I can log.
local sources = { "snippets", "buffer", "dictionary" }

if sql_filetypes[vim.bo.filetype] ~= nil then
sources = vim.list_extend(sources, { "dadbod" })
elseif is_dap_buffer() then
sources = vim.list_extend(sources, { "dap", "ripgrep", "path" })
elseif require("atro.utils").is_git_dir() then
-- ripgrep slows stuff down if the project is big, limiting to git repos only.
sources = vim.list_extend(sources, { "lsp", "ripgrep", "path" })
else
sources = vim.list_extend(sources, { "lsp", "path" })
end

log:with({ sources = sources }):info("Enabled CMP sources")

---@module 'blink.cmp'
---@type blink.cmp.Config
require("blink.cmp").setup({
Expand Down Expand Up @@ -93,21 +130,18 @@ return {
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = function()
local sql_filetypes = { mysql = true, sql = true }
if sql_filetypes[vim.bo.filetype] ~= nil then
return { "dadbod", "snippets", "buffer" }
elseif is_dap_buffer() then
return { "dap", "snippets", "buffer", "ripgrep" }
elseif require("atro.utils").is_git_dir() then
-- ripgrep slows stuff down if the project is big, limiting to git repos only.
return { "lsp", "path", "snippets", "buffer", "ripgrep" }
else
return { "lsp", "path", "snippets", "buffer" }
end
end,
default = sources,

providers = {
dictionary = {
module = "blink-cmp-dictionary",
name = "Dict",
min_keyword_length = 4, -- has to be at least 2
opts = {
dictionary_files = { dict_path },
},
score_offset = 50,
},
ripgrep = {
module = "blink-ripgrep",
name = "Ripgrep",
Expand All @@ -120,23 +154,23 @@ return {
-- The maximum file size that ripgrep should include in its search. Examples: "1024" (bytes by default), "200K", "1M", "1G"
max_filesize = "1M",
},
score_offset = 50,
score_offset = 51,
},
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
score_offset = 101,
},
dadbod = {
name = "Dadbod",
module = "vim_dadbod_completion.blink",
score_offset = 100,
score_offset = 102,
},
dap = {
name = "dap",
module = "blink.compat.source",
score_offset = 100,
score_offset = 103,
opts = {},
},
lsp = {
Expand Down

0 comments on commit 989d3c4

Please sign in to comment.