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