Comments (7)
If there are no spaces in the 'commentstring', there will be no spaces in the comment.
This is intentional. Feel free to contact the filetype plugin maintainers to change this in Vim.
from neovim.
When considered from the user's perspective.
That is not the only relevant perspective, though, and this was chosen as a deliberate compromise.
I understand that the filetype plugin is managed by another people and there is nothing you can do about it.
But you (who clearly care about this) can: contact the maintainer and ask them to add spaces. If they do, the changes will end up here and make you happy.
from neovim.
FWIW, the built in Vim comment plugin puts in the spaces, so nvim's behavior here differs from upstream Vim.
from neovim.
Okay, I'll use another plugin since it doesn't seem to solve the problem.
I just don't think it is appropriate as the default behavior.
from neovim.
It is exactly because it's default behavior that this is appropriate. It's supposed to be a minimal implementation leveraging existing builtin functionality, not being a VS Code kitchen sink. And, yes, using a more full-featured plugin because you need the additional functionality is perfectly fine (and also intended use).
from neovim.
It is exactly because it's default behavior that this is appropriate.
it may be appropriate in terms of implementation, but it is not appropriate when looking at just the function of commenting. When considered from the user's perspective.
VSCode is just an example of this. If you know an editor that does not use spaces, please let me know.
I understand that the filetype plugin is managed by another people and there is nothing you can do about it.
from neovim.
In case someone finds this having the same issue: if you want to have spaces in commentstring for every filetype without having to contact maintainers for every odd ftplugin, it can be done quite easily with an autocommand:
vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('commentstring_fix', {}),
callback = function(ctx)
local cms_value = vim.api.nvim_get_option_value(
'commentstring',
{buf = ctx.buf}
)
-- Note that this is the literal '%s'.
-- All other '%s' in this function are patterns.
local s_start, s_end = string.find(cms_value, '%s', 1, true)
if s_start == nil then
return
end
local s_before = s_start - 1
local s_after = s_end + 1
local s_prepend = ''
local s_append = ''
if s_start > 1
and string.find(
string.sub(cms_value, s_before, s_before),
'%s'
) == nil
then
s_prepend = ' '
end
if s_end < #cms_value
and string.find(
string.sub(cms_value, s_after, s_after),
'%s'
) == nil
then
s_append = ' '
end
if s_prepend ~= '' or s_append ~= '' then
vim.api.nvim_set_option_value(
'commentstring',
table.concat{
string.sub(cms_value, 1, s_before),
s_prepend,
'%s',
s_append,
string.sub(cms_value, s_after)
},
{buf = ctx.buf}
)
end
end
})
from neovim.
Related Issues (20)
- Cannot Use Help, constant `treesitter/highlighter.win` error messages HOT 13
- [spam]
- Windows: E303 swap error paths starting with `\\?\`
- Add support for Nerd Fonts (doublewidth icons) HOT 4
- can not change cursor color in st(suckless simple terminal) HOT 2
- Detect FAT filesystem explicitly in `time_differs` HOT 2
- Nvim lsp code action send doesn't respect encoding HOT 2
- Have terminal buffer lines not split with new lines HOT 1
- In ssh session, neovim doesn't set osc52 provider even though all conditions are true HOT 5
- Document the 0.10 behavior regarding termguicolors HOT 5
- Unexpected active treesitter parser (vim.treesitter.stop() doesn't detach parser) HOT 19
- All syntax coloring is gone. HOT 1
- extmarks wont get restored with {right_gravity=true,invalidate=true,undo_restore=true} opts HOT 1
- LSP: vim.lsp.rpc.connect() with hostname instead of IP address HOT 5
- :Tutor shows check mark on to-delete lines HOT 3
- Support for attaching popup window to an LSP for limited calls HOT 2
- fails to start if vcruntime140.dll is missing (windows server 2022) HOT 7
- Editing a file over scp fails on Windows
- Diff: `foldclose` and `wrap` don't sync
- Add alternatives to deprecated functions to doc comments HOT 5
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 neovim.