From 1981113faa12ad86128440779197d68421f6d41d Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 4 Mar 2023 20:01:01 +0100 Subject: [PATCH] nvim: fix insert_modeline with empty commentstring, add (no)wrap --- .config/nvim/lua/my/functions.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.config/nvim/lua/my/functions.lua b/.config/nvim/lua/my/functions.lua index 174a6c8..f37e398 100644 --- a/.config/nvim/lua/my/functions.lua +++ b/.config/nvim/lua/my/functions.lua @@ -29,6 +29,9 @@ vim.api.nvim_create_autocmd({ 'BufWritePre' }, { -- Insert or update a modeline at the bottom of the buffer function M.insert_modeline() local comment_string = vim.o.commentstring + if comment_string == '' then + comment_string = '%s' + end local space_maybe = '' if string.match(comment_string, '%%s(.*)') ~= '' then space_maybe = ' ' @@ -47,6 +50,7 @@ function M.insert_modeline() ' tw=' .. vim.o.textwidth, ' ft=' .. vim.o.filetype, (vim.o.spell and ' spell' .. ' spl=' .. vim.o.spelllang or ''), + (vim.o.wrap and ' wrap' or ' nowrap'), ':', space_maybe }