uga-rosa / cmp-dictionary

A dictionary completion source for nvim-cmp
MIT License
236 stars 16 forks source link

incorrectly loaded dictionaries per filetype #46

Closed m33mt33n closed 11 months ago

m33mt33n commented 1 year ago

my config (minimal):

local dict = require("cmp_dictionary") dict.setup({ exact = 2, first_case_insensitive = false, document = false, document_command = "wn %s -over", async = true, sqlite = false, max_items = 1000, capacity = 5, debug = false, })

local google_10k = '/usr/share/dict/google-10000-english.txt' filetype = { python = {vim.g.pydiction_location, google_10k}, lua = google_10k, }, spelllang = { en = "/usr/share/dict/google-10000-english.txt", }, })

• with above config when I edited a python file dictionaries seems to be loaded fine, but when I switched to a lua file during editing, items from 'python only' dictionary are also present in completion menu, am I doing something wrong with config??? or what can be done to make cmp using dictionaries set for lua while in lua buffer?

uga-rosa commented 1 year ago

This is not a normal lua code. Please copy it properly. Also, please use code block because it is hard to read.

m33mt33n commented 1 year ago

• sorry for mistake in lua code, I was at some mobile device with poor browsers (code blocks button not working), here is the updated code (code blocks still not working)

local dict = require("cmp_dictionary")
dict.setup({
  exact = 2,
  first_case_insensitive = false,
  document = false,
  document_command = "wn %s -over",
  async = true,
  sqlite = false,
  max_items = 1000,
  capacity = 5,
  debug = false,
})

local google_10k = '/usr/share/dict/google-10000-english.txt'
dict.switcher({
  filetype = {
    python   = {vim.g.pydiction_location, google_10k},
    lua      = google_10k,
  },
  spelllang = {
    en = "/usr/share/dict/google-10000-english.txt",
  },
})
uga-rosa commented 1 year ago

When you switch from python to lua file and the dictionary goes wrong, can you run this command and let me know the result?

:lua= vim.opt_local.dictionary:get()
uga-rosa commented 1 year ago

I guessed the cause and fixed it. Please try the latest version to see if it is fixed.

m33mt33n commented 1 year ago

1) lua= vim.opt_local.dictionary:get()

output of above command is: for lua file: { "/usr/share/dict/google-10000-english.txt } for python file: { "/usr/home/.vims/plugins/non_forked/pydiction/complete-dict", "/usr/share/dict/google-10000-english.txt" }

2) I tried your suggested latest version (clone of this repo) but it has same issue too.

uga-rosa commented 1 year ago

Create a stand-alone minimal init.lua that can reproduce this issue. It is difficult to fix a problem that cannot be reproduced. This would be helpful. https://github.com/hrsh7th/nvim-cmp/blob/main/utils/vimrc.vim

uga-rosa commented 11 months ago

I am closing this because I have not received a reply in over a month. If there is any progress, please reopen.