mirror of
https://github.com/Tilo-K/neovim-config.git
synced 2026-07-03 13:43:02 +00:00
add format on save
This commit is contained in:
22
init.lua
22
init.lua
@@ -47,7 +47,7 @@ require('lazy').setup({
|
|||||||
|
|
||||||
-- Useful status updates for LSP
|
-- Useful status updates for LSP
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||||
{ 'j-hui/fidget.nvim',tag = 'legacy', opts = {} },
|
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
||||||
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
-- Additional lua configuration, makes nvim stuff amazing!
|
||||||
'folke/neodev.nvim',
|
'folke/neodev.nvim',
|
||||||
@@ -590,7 +590,7 @@ vim.api.nvim_set_keymap('n', '<Leader>m', '<cmd>lua require("harpoon.mark").add_
|
|||||||
{ noremap = true, silent = true })
|
{ noremap = true, silent = true })
|
||||||
vim.api.nvim_set_keymap('n', '<Leader><Tab>', '<cmd>lua require("harpoon.ui").toggle_quick_menu()<CR>',
|
vim.api.nvim_set_keymap('n', '<Leader><Tab>', '<cmd>lua require("harpoon.ui").toggle_quick_menu()<CR>',
|
||||||
{ noremap = true, silent = true })
|
{ noremap = true, silent = true })
|
||||||
]]--
|
]] --
|
||||||
|
|
||||||
local harpoon = require('harpoon')
|
local harpoon = require('harpoon')
|
||||||
harpoon:setup({
|
harpoon:setup({
|
||||||
@@ -605,7 +605,7 @@ vim.keymap.set("n", "<Leader><Tab>", function() harpoon.ui:toggle_quick_menu(har
|
|||||||
vim.keymap.set("n", "<Leader>m", function() harpoon:list():append() end,
|
vim.keymap.set("n", "<Leader>m", function() harpoon:list():append() end,
|
||||||
{ desc = "Append file to harpoon list" })
|
{ desc = "Append file to harpoon list" })
|
||||||
|
|
||||||
vim.keymap.set("n", "<Leader>1", function() harpoon:list():select(1)end,
|
vim.keymap.set("n", "<Leader>1", function() harpoon:list():select(1) end,
|
||||||
{ desc = "Open File No 1" })
|
{ desc = "Open File No 1" })
|
||||||
vim.keymap.set("n", "<Leader>2", function() harpoon:list():select(2) end,
|
vim.keymap.set("n", "<Leader>2", function() harpoon:list():select(2) end,
|
||||||
{ desc = "Open File No 2" })
|
{ desc = "Open File No 2" })
|
||||||
@@ -659,3 +659,19 @@ require('lspconfig').rust_analyzer.setup {
|
|||||||
require("cmp").config.formatting = {
|
require("cmp").config.formatting = {
|
||||||
format = require("tailwindcss-colorizer-cmp").formatter
|
format = require("tailwindcss-colorizer-cmp").formatter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- 1
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
||||||
|
callback = function(args)
|
||||||
|
-- 2
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
-- 3
|
||||||
|
buffer = args.buf,
|
||||||
|
callback = function()
|
||||||
|
-- 4 + 5
|
||||||
|
vim.lsp.buf.format { async = false, id = args.data.client_id }
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user