Skip to content

Commit

Permalink
Update .config/nvim/lua/plugins/none-ls.lua
Browse files Browse the repository at this point in the history
Update .config/nvim/lua/plugins/nvim-lspconfig.lua
  • Loading branch information
Hyuga-Tsukui committed Nov 22, 2024
1 parent 4f8e2e8 commit eafb1af
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
35 changes: 31 additions & 4 deletions dot_config/nvim/lua/plugins/none-ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,41 @@ return {
config = function()
require("mason").setup()
require("mason-null-ls").setup({
handlers = {},
handlers = {
prettierd = function() end, -- prettierd の自動セットアップを無効化
biome = function() end, -- biome の自動セットアップを無効化
},
})

local null_ls = require("null-ls")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})

-- JavaScript プロジェクト用のフォーマッター選択
local function javascript_project()
local biome_config = vim.fn.findfile("biome.json", ".;")
if biome_config ~= "" then
print("Using biome with biome.json")
return {
null_ls.builtins.formatting.biome.with({
extra_args = { "--config", biome_config }, -- biome.json を明示的に指定
}),
}
else
print("Using prettierd")
return {
null_ls.builtins.formatting.prettierd.with({
cwd = vim.fn.getcwd(),
}),
}
end
end

-- null-ls のセットアップ
null_ls.setup({
sources = {
null_ls.builtins.formatting.terraform_fmt,
},
-- sources の結合
sources = vim.list_extend({
null_ls.builtins.formatting.terraform_fmt, -- デフォルト
}, javascript_project()), -- JavaScript プロジェクト用のフォーマッター
on_attach = function(client, bufnr)
vim.keymap.set("n", "<space>f", function()
vim.lsp.buf.format({ async = true })
Expand Down
6 changes: 6 additions & 0 deletions dot_config/nvim/lua/plugins/nvim-lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ return {
},
})
end,

["biome"] = function()
lspconfig.biome.setup({
cmd = { "npx", "biome", "lsp-proxy" },
})
end,
})

-- Lsp Keymaps.
Expand Down

0 comments on commit eafb1af

Please sign in to comment.