Comments (1)
You cannot do it with neovim options but by creating a custom function for checking the current line which is already commented is of certain length. And if it exceeds that you can split it from there and comment the next line. Then you can create a autocomand for checking the it whenever trying to coment any line.
Code can be something like this
function splitLineComment(length_limit)
-- Get the current line
local line_text = vim.api.nvim_get_current_line()
-- Check if the line is a line comment
if line_text:match('^%s*//%s*') then
-- Check if the comment exceeds the length limit
local comment_text = line_text:gsub('^%s*//%s*', '')
if #comment_text > length_limit then
-- Split the comment onto a new line
local split_text = comment_text:sub(1, length_limit - 1)
local remaining_text = comment_text:sub(length_limit)
local new_line_text = '// ' .. split_text
local next_line_number = vim.api.nvim_win_get_cursor(0)[1] + 1
-- Insert the new line with the split comment
vim.api.nvim_buf_set_lines(0, next_line_number - 1, next_line_number - 1, false, {new_line_text})
-- Remove the split portion from the original line
vim.api.nvim_set_current_line(line_text:gsub(comment_text, remaining_text))
end
end
end
-- Map the function to a key combination
vim.api.nvim_set_keymap('n', '<Leader>s', ':lua splitLineComment(80)<CR>', {noremap = true})
some minor changes and autocommand and you're good to go.
from nvstar.
Related Issues (4)
- Important Message HOT 1
- Packer not installing plugins HOT 8
- Cursor animation plugin HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvstar.