add conform for formatting
This commit is contained in:
parent
2b88ac6e5d
commit
4b24a13263
3 changed files with 152 additions and 135 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
||||
"LuaSnip": { "branch": "master", "commit": "57c9f5c31b3d712376c704673eac8e948c82e9c1" },
|
||||
"catppuccin": { "branch": "main", "commit": "079500a625f3ae5aa6efb758f1a17fe4c7a57e52" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
||||
"fzf": { "branch": "master", "commit": "d21d5c9510170d74a7f959309da720b6df72ca01" },
|
||||
"fzf-lua": { "branch": "main", "commit": "a1a2d0f42eaec400cc6918a8e898fc1f9c4dbc5f" },
|
||||
|
|
@ -35,6 +36,7 @@
|
|||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "6213322ab56eb27356fdc09a5078e41e3ea7f3bc" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" },
|
||||
"undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" },
|
||||
"vim-closetag": { "branch": "master", "commit": "d0a562f8bdb107a50595aefe53b1a690460c3822" },
|
||||
"vim-floaterm": { "branch": "master", "commit": "3f01a623376957437f9376327637491b74719e38" },
|
||||
|
|
|
|||
|
|
@ -1,34 +1,48 @@
|
|||
return {
|
||||
-- lspconfig
|
||||
{
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v2.x',
|
||||
"VonHeikemen/lsp-zero.nvim",
|
||||
branch = "v2.x",
|
||||
dependencies = {
|
||||
-- LSP Support
|
||||
{ 'neovim/nvim-lspconfig' }, -- Required
|
||||
{ "neovim/nvim-lspconfig" }, -- Required
|
||||
{
|
||||
-- Optional
|
||||
'williamboman/mason.nvim',
|
||||
"williamboman/mason.nvim",
|
||||
build = function()
|
||||
pcall(vim.cmd, 'MasonUpdate')
|
||||
pcall(vim.cmd, "MasonUpdate")
|
||||
end,
|
||||
},
|
||||
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
|
||||
{ "williamboman/mason-lspconfig.nvim" }, -- Optional
|
||||
|
||||
-- Autocompletion
|
||||
{ 'hrsh7th/nvim-cmp' }, -- Required
|
||||
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
|
||||
{ 'L3MON4D3/LuaSnip' }, -- Required
|
||||
{ "hrsh7th/nvim-cmp" }, -- Required
|
||||
{ "hrsh7th/cmp-nvim-lsp" }, -- Required
|
||||
{ "L3MON4D3/LuaSnip" }, -- Required
|
||||
|
||||
-- Neovim Plugin Development Completions
|
||||
{
|
||||
'folke/neodev.nvim',
|
||||
"folke/neodev.nvim",
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- formatting
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
-- required to setup neodev before lspconfig
|
||||
require('neodev').setup({})
|
||||
require("neodev").setup({})
|
||||
|
||||
local lspzero = require("lsp-zero")
|
||||
|
||||
|
|
@ -38,22 +52,17 @@ return {
|
|||
lspzero.default_keymaps({
|
||||
buffer = bufnr,
|
||||
omit = {
|
||||
'gr'
|
||||
"gr",
|
||||
},
|
||||
})
|
||||
|
||||
function nmap(key, action, desc)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
key,
|
||||
action,
|
||||
{
|
||||
vim.keymap.set("n", key, action, {
|
||||
desc = "LSP: " .. desc,
|
||||
}
|
||||
)
|
||||
})
|
||||
end
|
||||
|
||||
nmap("[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", "Goto Prev Diagnostic");
|
||||
nmap("[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", "Goto Prev Diagnostic")
|
||||
nmap("]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", "Goto Next Diagnostic")
|
||||
|
||||
local current_dir = vim.fn.expand("%:p:h")
|
||||
|
|
@ -64,6 +73,10 @@ return {
|
|||
-- vim.keymap.set("n", "<leader>fb", "<cmd>lua vim.lsp.buf.format()<CR>",
|
||||
-- { desc = "[F]ormat [B]uffer" })
|
||||
nmap("<leader>fb", "<cmd>lua vim.lsp.buf.format()<CR>", "[F]ormat [B]uffer")
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
||||
require("conform").format({ bufnr = bufnr })
|
||||
end, { desc = "Format current buffer with LSP" })
|
||||
end)
|
||||
|
||||
lspzero.ensure_installed({
|
||||
|
|
@ -72,23 +85,23 @@ return {
|
|||
"tailwindcss",
|
||||
})
|
||||
|
||||
lspzero.format_on_save({
|
||||
format_ops = {
|
||||
async = true,
|
||||
timeout_ms = 10000,
|
||||
},
|
||||
servers = {
|
||||
["lua_ls"] = { "lua" },
|
||||
["null-ls"] = {
|
||||
"javascript",
|
||||
"typescript",
|
||||
"javascriptreact",
|
||||
"typescriptreact",
|
||||
"html",
|
||||
"css",
|
||||
},
|
||||
},
|
||||
})
|
||||
-- lspzero.format_on_save({
|
||||
-- format_ops = {
|
||||
-- async = true,
|
||||
-- timeout_ms = 10000,
|
||||
-- },
|
||||
-- servers = {
|
||||
-- ["lua_ls"] = { "lua" },
|
||||
-- ["null-ls"] = {
|
||||
-- "javascript",
|
||||
-- "typescript",
|
||||
-- "javascriptreact",
|
||||
-- "typescriptreact",
|
||||
-- "html",
|
||||
-- "css",
|
||||
-- },
|
||||
-- },
|
||||
-- })
|
||||
|
||||
local status, lspconfig = pcall(require, "lspconfig")
|
||||
|
||||
|
|
@ -96,18 +109,18 @@ return {
|
|||
lspconfig.tsserver.setup({})
|
||||
lspconfig.tailwindcss.setup({
|
||||
filetypes = {
|
||||
'templ',
|
||||
'html',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'javascriptreact',
|
||||
'typescriptreact',
|
||||
"templ",
|
||||
"html",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"javascriptreact",
|
||||
"typescriptreact",
|
||||
},
|
||||
init_options = {
|
||||
userLanguages = {
|
||||
templ = "html"
|
||||
}
|
||||
}
|
||||
templ = "html",
|
||||
},
|
||||
},
|
||||
})
|
||||
lspconfig.zls.setup({})
|
||||
lspconfig.rust_analyzer.setup({})
|
||||
|
|
@ -115,7 +128,7 @@ return {
|
|||
lspconfig.html.setup({})
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
templ = "templ"
|
||||
templ = "templ",
|
||||
},
|
||||
})
|
||||
lspconfig.templ.setup({
|
||||
|
|
@ -130,15 +143,17 @@ return {
|
|||
local cmp
|
||||
status, cmp = pcall(require, "cmp")
|
||||
|
||||
if not status then return end
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
-- press 'enter' to confirm completion/suggestion
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue