Updated config
Added conform to replace null-ls
This commit is contained in:
@@ -18,12 +18,6 @@ local M = {
|
|||||||
["<leader>0"] = { "0", desc = "Go to true line beggining" },
|
["<leader>0"] = { "0", desc = "Go to true line beggining" },
|
||||||
["<leader>q"] = { ":noh<CR>", desc = "Clear highlights" },
|
["<leader>q"] = { ":noh<CR>", desc = "Clear highlights" },
|
||||||
-- buffer
|
-- buffer
|
||||||
["<leader>bf"] = {
|
|
||||||
function()
|
|
||||||
vim.lsp.buf.format({ async = false })
|
|
||||||
end,
|
|
||||||
desc = "Format buffer",
|
|
||||||
},
|
|
||||||
["<leader>bs"] = { ":write <CR>", desc = "Save buffer" },
|
["<leader>bs"] = { ":write <CR>", desc = "Save buffer" },
|
||||||
["<C-k>"] = { "<cmd>cnext<CR>zz" },
|
["<C-k>"] = { "<cmd>cnext<CR>zz" },
|
||||||
["<C-j>"] = { "<cmd>cprev<CR>zz" },
|
["<C-j>"] = { "<cmd>cprev<CR>zz" },
|
||||||
|
|||||||
38
lua/taken/plugins/conform.lua
Normal file
38
lua/taken/plugins/conform.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
return {
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
config = function()
|
||||||
|
require("conform").setup({
|
||||||
|
formatters_by_ft = {
|
||||||
|
lua = { "stylua" },
|
||||||
|
javascript = { "dprint" },
|
||||||
|
typescript = { "dprint" },
|
||||||
|
json = { "dprint" },
|
||||||
|
markdown = { "dprint" },
|
||||||
|
},
|
||||||
|
format_on_save = {
|
||||||
|
timeout_ms = 500,
|
||||||
|
lsp_format = "fallback",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("Format", function(args)
|
||||||
|
local range = nil
|
||||||
|
if args.count ~= -1 then
|
||||||
|
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||||
|
range = {
|
||||||
|
start = { args.line1, 0 },
|
||||||
|
["end"] = { args.line2, end_line:len() },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
||||||
|
end, { range = true })
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap(
|
||||||
|
"n",
|
||||||
|
"<leader>bf",
|
||||||
|
"<cmd>Format<CR>",
|
||||||
|
{ noremap = true, silent = true, desc = "Format buffer" }
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
}
|
||||||
@@ -3,12 +3,14 @@ return {
|
|||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
"jayp0521/mason-null-ls.nvim",
|
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||||
|
-- "jayp0521/mason-null-ls.nvim",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local mason = require("mason")
|
local mason = require("mason")
|
||||||
local mason_lspconfig = require("mason-lspconfig")
|
local mason_lspconfig = require("mason-lspconfig")
|
||||||
local mason_null_ls = require("mason-null-ls")
|
local mason_tool_installer = require("mason-tool-installer")
|
||||||
|
-- local mason_null_ls = require("mason-null-ls")
|
||||||
|
|
||||||
mason.setup({
|
mason.setup({
|
||||||
ui = {
|
ui = {
|
||||||
@@ -36,12 +38,22 @@ return {
|
|||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
mason_null_ls.setup({
|
mason_tool_installer.setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"stylua",
|
"stylua",
|
||||||
"prettier",
|
"prettier",
|
||||||
|
"dprint",
|
||||||
},
|
},
|
||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- mason_null_ls.setup({
|
||||||
|
-- ensure_installed = {
|
||||||
|
-- "stylua",
|
||||||
|
-- "prettier",
|
||||||
|
-- "dprint",
|
||||||
|
-- },
|
||||||
|
-- automatic_installation = true,
|
||||||
|
-- })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
return {
|
return {
|
||||||
"nvimtools/none-ls.nvim",
|
"nvimtools/none-ls.nvim",
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
enabled = false,
|
||||||
config = function()
|
config = function()
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
local formatting = null_ls.builtins.formatting
|
local formatting = null_ls.builtins.formatting
|
||||||
local diagnostics = null_ls.builtins.diagnostics
|
|
||||||
|
|
||||||
local root_has_file = function(files)
|
local root_has_file = function(files)
|
||||||
return function(utils)
|
return function(utils)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ return {
|
|||||||
|
|
||||||
local on_attach = require("taken.utils.on_attach")
|
local on_attach = require("taken.utils.on_attach")
|
||||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||||
local augroup = vim.api.nvim_create_augroup("Typescript_tools", {})
|
|
||||||
|
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
local tsserver_path = cwd .. "/node_modules/.bin/tsserver"
|
local tsserver_path = cwd .. "/node_modules/.bin/tsserver"
|
||||||
@@ -26,7 +25,6 @@ return {
|
|||||||
else
|
else
|
||||||
cmd = "typescript-language-server"
|
cmd = "typescript-language-server"
|
||||||
end
|
end
|
||||||
local prettier_config = vim.fn.glob(cwd .. "/*prettierrc*", false, true)
|
|
||||||
|
|
||||||
typescript_tools.setup({
|
typescript_tools.setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
@@ -35,19 +33,6 @@ return {
|
|||||||
if cmd == "typescript-language-server" then
|
if cmd == "typescript-language-server" then
|
||||||
print("Using global tsserver")
|
print("Using global tsserver")
|
||||||
end
|
end
|
||||||
if prettier_config == "" then
|
|
||||||
print("Using prettier to format")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
||||||
group = augroup,
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = function()
|
|
||||||
vim.lsp.buf.format({ async = false })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
settings = {
|
settings = {
|
||||||
cmd = { cmd, "--stdio" },
|
cmd = { cmd, "--stdio" },
|
||||||
|
|||||||
@@ -74,6 +74,14 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
window = {
|
||||||
|
completion = {
|
||||||
|
scrollbar = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
|
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
|
||||||
luasnip.jump(1)
|
luasnip.jump(1)
|
||||||
end, { silent = true })
|
end, { silent = true })
|
||||||
|
|||||||
Reference in New Issue
Block a user