diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-04-28 12:49:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-28 12:49:25 +0200 |
commit | 4625394a767fab311f75ef40f4f15c661156e071 (patch) | |
tree | fe97624375a4c5484ab5678d0ab45b8f99cff3b2 /test/functional/lua/snippet_spec.lua | |
parent | c3061a40f7012b4cd9afcaa6e8b856e946aed528 (diff) | |
download | rneovim-4625394a767fab311f75ef40f4f15c661156e071.tar.gz rneovim-4625394a767fab311f75ef40f4f15c661156e071.tar.bz2 rneovim-4625394a767fab311f75ef40f4f15c661156e071.zip |
fix(snippet): do not add extra indent on newlines (#28538)
Reverts parts of https://github.com/neovim/neovim/pull/27674
LSP snippets typically do include tabs or spaces to add extra
indentation and don't rely on the client using `autoindent`
functionality.
For example:
public static void main(String[] args) {\n\t${0}\n}
Notice the `\t` after `{\n`
Adding spaces or tabs independent of that breaks snippets for languages
like Haskell where you can have snippets like:
${1:name} :: ${2}\n${1:name} ${3}= ${0:undefined}
To generate:
name ::
name = undefined
Diffstat (limited to 'test/functional/lua/snippet_spec.lua')
-rw-r--r-- | test/functional/lua/snippet_spec.lua | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua index 74f0869200..83bd91bc71 100644 --- a/test/functional/lua/snippet_spec.lua +++ b/test/functional/lua/snippet_spec.lua @@ -246,7 +246,7 @@ describe('vim.snippet', function() it('correctly indents with newlines', function() local curbuf = api.nvim_get_current_buf() test_expand_success( - { 'function($2)\n$3\nend' }, + { 'function($2)\n\t$3\nend' }, { 'function()', ' ', 'end' }, [[ vim.opt.sw = 2 @@ -255,7 +255,16 @@ describe('vim.snippet', function() ) api.nvim_buf_set_lines(curbuf, 0, -1, false, {}) test_expand_success( - { 'func main() {\n$1\n}' }, + { 'function($2)\n$3\nend' }, + { 'function()', '', 'end' }, + [[ + vim.opt.sw = 2 + vim.opt.expandtab = true + ]] + ) + api.nvim_buf_set_lines(curbuf, 0, -1, false, {}) + test_expand_success( + { 'func main() {\n\t$1\n}' }, { 'func main() {', '\t', '}' }, [[ vim.opt.sw = 4 @@ -263,5 +272,18 @@ describe('vim.snippet', function() vim.opt.expandtab = false ]] ) + api.nvim_buf_set_lines(curbuf, 0, -1, false, {}) + test_expand_success( + { '${1:name} :: ${2}\n${1:name} ${3}= ${0:undefined}' }, + { + 'name :: ', + 'name = undefined', + }, + [[ + vim.opt.sw = 4 + vim.opt.ts = 4 + vim.opt.expandtab = false + ]] + ) end) end) |