1
0
Fork 0

nvim: fix insert_modeline with empty commentstring, add (no)wrap

This commit is contained in:
tastytea 2023-03-04 20:01:01 +01:00
parent 298b215c3d
commit 1981113faa
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 4 additions and 0 deletions

View File

@ -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
}