diff --git a/roles/neovim/files/after/plugin/luasnip.lua b/roles/neovim/files/after/plugin/luasnip.lua index 3040ebe..6441b3a 100644 --- a/roles/neovim/files/after/plugin/luasnip.lua +++ b/roles/neovim/files/after/plugin/luasnip.lua @@ -39,11 +39,13 @@ end local javascript = make(R "opdavies.snippets.ft.javascript") local markdown = make(R "opdavies.snippets.ft.markdown") local php = make(R "opdavies.snippets.ft.php") +local rst = make(R "opdavies.snippets.ft.rst") local snippets = { js = javascript, markdown = markdown, php = php, + rst = rst, typescript = javascript, vue = javascript, } diff --git a/roles/neovim/files/lua/opdavies/snippets/ft/rst.lua b/roles/neovim/files/lua/opdavies/snippets/ft/rst.lua new file mode 100644 index 0000000..657dae1 --- /dev/null +++ b/roles/neovim/files/lua/opdavies/snippets/ft/rst.lua @@ -0,0 +1,22 @@ +local ls = require "luasnip" + +local i = ls.insert_node +local f = ls.function_node + +local fill_line = function(char) + return function() + local row = vim.api.nvim_win_get_cursor(0)[1] + local lines = vim.api.nvim_buf_get_lines(0, row - 2, row, false) + return string.rep(char, #lines[1]) + end +end + +local M = { + link = { ".. _", i(1), ":" }, + + head = f(fill_line "=", {}), + sub = f(fill_line "-", {}), + subsub = f(fill_line "^", {}), +} + +return M