Make conform respect config.vim.lsp.formatOnSave and config.vim.lsp.mappings.toggleFormatOnSave - #768
Make conform respect config.vim.lsp.formatOnSave and config.vim.lsp.mappings.toggleFormatOnSave#768venkyr77 wants to merge 1 commit into
Conversation
|
@horriblename, fixes #764 (comment) |
| else | ||
| return ${toLuaObject defaultFormatAfterSaveOpts} |
There was a problem hiding this comment.
nit: no else return
| else | ||
| return ${toLuaObject defaultFormatOnSaveOpts} |
There was a problem hiding this comment.
nit: no else return
if the changes look good, I can make a fast followup
943b343 to
7eec1d2
Compare
horriblename
left a comment
There was a problem hiding this comment.
Looks good other than some documentation stuff
| in | ||
| mkOption { | ||
| type = nullOr (either attrs luaInline); | ||
| default = |
There was a problem hiding this comment.
add a defaultText that says something like "enabled with LSP format as fallback, respecting vim.lsp.formatOnSave and vim.lsp.mappings.toggleFormatOnSave"
There was a problem hiding this comment.
also: use lib.options.literalMD in the defaultText
| type = nullOr (either attrs luaInline); | ||
| default = | ||
| mkLuaInline | ||
| # lua |
There was a problem hiding this comment.
| # lua |
Please don't do this. I understand it's easier to handle the code with syntax highlighting, but we don't inject syntax anywhere else in the source tree and Alejandra results in horrible formatting when you specific a language.
Easier if we provide injections for mkLuaInline, CC @horriblename
There was a problem hiding this comment.
fwiw, I find flaw in both approaches. Ours require custom query rules for each option we want to support which is tedious, and theirs enforce a style of coding that is usually not in line with official language guidelines just to support a feature in a text editor plugin not everyone uses
There was a problem hiding this comment.
Please don't do this
removed
| end | ||
| ''; | ||
| description = '' | ||
| Table or function(lualinline) that will be passed to `conform.format()`. If this |
There was a problem hiding this comment.
| Table or function(lualinline) that will be passed to `conform.format()`. If this | |
| Table or function(lualinline) that will be passed to `conform.format()`. If this |
Is this a function that takes luainline as an argument?
There was a problem hiding this comment.
Is this a function that takes luainline as an argument?
it can take both
a table or a function that returns table
There was a problem hiding this comment.
Okay, I'm mostly confused about the role of the paranthesis in the description. Does it indicate function arguments?
I think it's better to clarify the wording to state the types properly.
| Table or function(lualinline) that will be passed to `conform.format()`. If this | |
| Attribute set or or a Lua function that will be passed to `conform.format()`. |
Or similar.
…appings.toggleFormatOnSave
7eec1d2 to
0ffd832
Compare
|
Diff addressing all the comments - https://github.com/NotAShelf/nvf/compare/7eec1d28d2a8f510964f304fb460884ef9f48b4c..0ffd8321e9fee37e3f191209921546a40523a269 |
|
NotAShelf
left a comment
There was a problem hiding this comment.
Two small notes on the documentation. I have nothing further to nit (for once)
Perhaps a changelog entry would also go very well with the spirit of this change?
| end | ||
| ''; | ||
| description = '' | ||
| Table or function(lualinline) that will be passed to `conform.format()`. If this |
There was a problem hiding this comment.
Okay, I'm mostly confused about the role of the paranthesis in the description. Does it indicate function arguments?
I think it's better to clarify the wording to state the types properly.
| Table or function(lualinline) that will be passed to `conform.format()`. If this | |
| Attribute set or or a Lua function that will be passed to `conform.format()`. |
Or similar.
| Table or function(luainline) that will be passed to `conform.format()`. If this | ||
| is set, Conform will run the formatter asynchronously after save. |
| in | ||
| mkOption { | ||
| type = nullOr (either attrs luaInline); | ||
| default = mkLuaInline '' |
There was a problem hiding this comment.
add defaultText please
something like
defaultText = literalMD "enabled, with fallback to LSP formatting that respects `vim.lsp.formatOnSave` and `vim.lsp.mappingd.toggleFormatSave`"
|
superseded by #891 |
|
✅ Preview has been deleted successfully! |
Update of PR #764
The current defaults(link1, link2)from conform config is not respecting the top level config we have for
formatOnSave- vim.lsp.formatOnSave. Also,config.vim.lsp.mappings.toggleFormatOnSavehas no impact.From conform docs
these need to be set to
null(ornilinlua) whenconfig.vim.lsp.formatOnSaveisfalseThis PR fixes conform config to respect
config.vim.lsp.formatOnSaveTesting:
Tested my changes by changing the
nvfurl to the branch from my forkwith
config.vim.lsp.formatOnSave = false;conform is not auto formatting the filewith
config.vim.lsp.formatOnSave = true;with
config.vim.lsp.formatOnSave = true;and using the mapping forconfig.vim.lsp.mappings.toggleFormatOnSaveSanity Checking
nix fmt).#nix(default package).#maximal.#docs-html(manual, must build).#docs-linkcheck(optional, please build if adding links)x86_64-linuxaarch64-linuxx86_64-darwinaarch64-darwinAdd a 👍 reaction to pull requests you find important.