uga-rosa / cmp-dictionary

A dictionary completion source for nvim-cmp
MIT License
237 stars 17 forks source link

HOWTO: Configure per filetype #1

Closed eronde closed 2 years ago

eronde commented 2 years ago

Hello, Thank you for your time to create this plugin. If you want configure this plugin per filetype, I found this way:

Setup per filetype

Example ftplugin/markdown.lua

--settings for markdown ft
--vim.opt.dictionary=vim.opt.dictionary + "......."

packer

To use cmp-user_dictionary per filetype, you need to set the ft option in packer so cmp-user_dictionary will only load after the ftplugin. This avoids that the plugin is loaded before the dictionary is set.

    use {"uga-rosa/cmp-user_dictionary",ft={"text","markdown"}}
uga-rosa commented 2 years ago

Thank you for using it.

That setting only delays the loading, so if you open another file after the markdown, this source will be used. You can choose the source to use for each file type, not only for this plugin. Example

autocmd FileType markdown lua require('cmp').setup.buffer { sources = {{name = "buffer"}, {name = "user_dictionary"} }

cmp.setup.buffer is a function to override some settings locally in the buffer.

uga-rosa commented 2 years ago

You can also set the dictionary for each file type with setlocal, but the current design only reads the dictionary at the beginning, so I'll improve it.

uga-rosa commented 2 years ago

You can also set the dictionary for each file type with setlocal, but the current design only reads the dictionary at the beginning, so I'll improve it.

Implemented.

uga-rosa commented 2 years ago

Please see the readme for the information you may need.

eronde commented 2 years ago

:pray:

uga-rosa commented 2 years ago

3