Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
home (nvim): Configure luasnip to load custom lua snippets
The `path` option passed to `fromLua` needs to point to a directory with a particular structure: The directory needs to contain either files with name `<file-type>.lua` or subdirectories named after the file type they apply to. See [this section](https://github.com/L3MON4D3/LuaSnip/blob/master/README.md#add-snippets) of luasnip's documentation for more details. The lua files themselves also have to follow a certain structure. First of all common luasnip imports such as `local s = ls.snippet` don't need to be added because they a brought into scope automatically (see the documentation above, and https://github.com/L3MON4D3/LuaSnip/blob/0f7bbce41ea152a94d12aea286f2ce98e63c0f58/lua/luasnip/default_config.lua#L20-L99 for all automatically imported symbols. Furthermore each lua file needs to return a list with two entries. The first entry being normal snippets and the second one being auto snippets. In order for snippets to show up in cmp's popup menu each snippet needs to define a `trig` and a `desc`. If this is missing, cmp won't show them! Keymappings for jumping between placeholders in the snippet are added, because otherwise insert nodes don't make sense. A keymapping for cycling through choises of choise nodes is currently missing, because none of the snippets uses choise at the moment. Last but not least a single snippet for generating a NixOS module including an enable option is added. The snippet allows for defining the option namespace, generates an enable option using the file name without extension for the enable option paramter, assigns a cfg variable, and adds the typical `config = lib.mkIf cfg.enable {}` block.
- Loading branch information