formatting
This commit is contained in:
@@ -4,6 +4,7 @@ require("romanzy.plugins.lazygit")
|
||||
require("romanzy.plugins.oil")
|
||||
require("romanzy.plugins.telescope")
|
||||
require("romanzy.plugins.nvim-treesitter")
|
||||
require("romanzy.plugins.conform")
|
||||
require("romanzy.plugins.lsp")
|
||||
-- require("romanzy.plugins.header42")
|
||||
|
||||
|
||||
19
nvim/.config/nvim/lua/romanzy/plugins/conform.lua
Normal file
19
nvim/.config/nvim/lua/romanzy/plugins/conform.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/stevearc/conform.nvim",
|
||||
name = "conform.nvim",
|
||||
},
|
||||
})
|
||||
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
javascript = { "prettier" },
|
||||
javascriptreact = { "prettier" },
|
||||
typescript = { "prettier" },
|
||||
typescriptreact = { "prettier" },
|
||||
},
|
||||
format_on_save = {
|
||||
lsp_format = "fallback",
|
||||
timeout_ms = 2000,
|
||||
},
|
||||
})
|
||||
@@ -18,7 +18,6 @@ local mason_lspconfig = require("mason-lspconfig")
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect", "popup", "fuzzy" }
|
||||
vim.opt.pumheight = 8
|
||||
|
||||
local format_augroup = vim.api.nvim_create_augroup("RomanzyFormatOnSave", { clear = true })
|
||||
local diag_inline_enabled = true
|
||||
|
||||
local function diag_virtual_text()
|
||||
@@ -60,26 +59,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = format_augroup,
|
||||
callback = function(ev)
|
||||
local bufnr = ev.buf
|
||||
|
||||
if not vim.bo[bufnr].modifiable or vim.bo[bufnr].buftype ~= "" then
|
||||
return
|
||||
end
|
||||
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
async = false,
|
||||
timeout_ms = 2000,
|
||||
filter = function(client)
|
||||
return client.supports_method("textDocument/formatting")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
local managed_servers = {
|
||||
"bashls",
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
"plugins": {
|
||||
"conform.nvim": {
|
||||
"rev": "619363c30309d29ffa631e67c8183f2a72caa373",
|
||||
"src": "https://github.com/stevearc/conform.nvim"
|
||||
},
|
||||
"header42.nvim": {
|
||||
"rev": "d41468df1c53081c909fc78248cf233893b59809",
|
||||
"src": "https://codeberg.org/42nerds/header42.nvim"
|
||||
|
||||
Reference in New Issue
Block a user