如何配置autoformat no lanar vim

发布于 2025-01-26 11:40:54 字数 304 浏览 2 评论 0原文

我在VIM和您的叉子上更新。要有一个光滑的过渡,我正在使用Lunar vim,但是我需要更改有关格式的一些选项,例如:

我需要如何格式化:

<img src={ item.image } alt ={ item.descripton } />

但是当我保存时,vim格式如:(

<img src={item.image} alt ={item.descripton} />

没有空格)

我需要更改这或删除自动格式。

I'm newer on vim and your forks. To have a smoother transition I'm using Lunar Vim, but I need to change some option about the formatter, for example:

How I need to format:

<img src={ item.image } alt ={ item.descripton } />

But when I save, the Vim format like:

<img src={item.image} alt ={item.descripton} />

(Without spaces)

I need to change this, or remove the auto formatter.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2025-02-02 11:40:54

有两种方法可以做到这一点,您可以用简单的方法(Jorge Dorino的答案)来做到这一点。

file:/home/user/.config/lvim/config.lua

lvim.format_on_save = true  -- Disable this line 

或您可以保留此行并激活Prettier Formtertert https://prettier.io/docs/en/options.html ,并将您自己的规则配置为HTML文件格式化。
(这样做之前,您需要安装Prettier或Prettierd)

文件:/home/user/.config/lvim/config.lua

  local formatters = require "lvim.lsp.null-ls.formatters"
  formatters.setup {
    { exe = "prettierd", filetypes = { "html" } }
  }

There are two ways to do this, you can do it with the easy way (answer of Jorge Dorino).

File: /home/user/.config/lvim/config.lua

lvim.format_on_save = true  -- Disable this line 

Or you can keep this line and activate the prettier formatter https://prettier.io/docs/en/options.html , and configure your own rules to html files formatting.
(You need to install prettier or prettierd before do this)

File: /home/user/.config/lvim/config.lua

  local formatters = require "lvim.lsp.null-ls.formatters"
  formatters.setup {
    { exe = "prettierd", filetypes = { "html" } }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文