minisnippets not taking from snippets from non default folder #2103
-
Contributing guidelines
Module(s)mini.snippets QuestionI've been trying to mini-snippets to read from the directory called ~/.config/nvim/lua/snippets, instead of the default location (The default location also did not work for me). I am unsure if my nonstandard format for directory is the issue. I have tried the following
Neither worked. I am using vim.pack as the package manager and neovim v0.12.0 nightly. The below here is my file for mini-snippets.lua which i import into my settings.lua file local snippets = require('mini.snippets')
local snippets_dir = vim.fn.stdpath('config') .. '/lua/snippets'
return require('mini.snippets').setup({
snippets.gen_loader.from_file( snippets_dir .. '/global.json'),
snippets.gen_loader.from_lang( { path = snippets_dir }),
mappings = {
expand = "<C-k>",
jump_next = "<C-j>",
jump_prev = "<C-n>",
stop = "<C-c>",
},
})# Directory layout for my repo
.
├── init.vim # using init.vim for vim only settings
├── lua
│ ├── lsp
│ ├── plugins
│ └── settings.lua # equivalent of init.lua
├── nvim-pack-lock.json
└── snippets
├── global.json # globals.json is as per provided in your documentation.
├── lua.json
└── python.jsonUnsure if this affects anything but i am using blinkcmp # Using blink.cmp using the mini_snippets as preset
require('blink.cmp').setup({
sources = { default = { 'lsp', 'path', 'snippets', 'buffer' }, },
snippets = { preset = 'mini_snippets' },The current error message i am getting is rather cryptic (mini.snippets) No snippets in context:
{
buf_id =1
lang = "lua"
}Any idea or next steps would be really appreciated!! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
There is But nevertheless, the issue seems to be that custom snippets should be configured inside local snippets = require('mini.snippets')
return require('mini.snippets').setup({
snippets = {
snippets.gen_loader.from_file(vim.fn.stdpath('config') .. '/snippets/global.json'),
snippets.gen_loader.from_lang(),
},
mappings = {
expand = '<C-k>',
jump_next = '<C-j>',
jump_prev = '<C-n>',
stop = '<C-c>',
},
}) |
Beta Was this translation helpful? Give feedback.
-
|
Apologies for the typo. Snippets were in the top location Thank you very much this works! |
Beta Was this translation helpful? Give feedback.
There is
local snippets_dir = vim.fn.stdpath('config') .. '/lua/snippets'line in the code, but the directory layout show that 'snippets/' is top directory in the config (i.e. `stdpath('config') .. '/snippets'). Would you mind checking where is the typo here?But nevertheless, the issue seems to be that custom snippets should be configured inside
config.snippetsdirectory, not top levelconfig. Here is the basic example. So assuming the directory layout is correct (i.e. there is '~/.config/nvim/snippets'), the following should work: