format lua code
This commit is contained in:
parent
4e394d4138
commit
622889647d
|
@ -33,3 +33,5 @@ map('n', '<leader>2', ':BufferLineGoToBuffer 2<CR>', opt)
|
|||
map('n', '<leader>3', ':BufferLineGoToBuffer 3<CR>', opt)
|
||||
map('n', '<leader>4', ':BufferLineGoToBuffer 4<CR>', opt)
|
||||
map('n', '<leader>5', ':BufferLineGoToBuffer 5<CR>', opt)
|
||||
map("n", "<leader>bp", ":BufferLineCyclePrev<CR>", opt)
|
||||
map("n", "<leader>bn", ":BufferLineCycleNext<CR>", opt)
|
||||
|
|
|
@ -11,3 +11,28 @@ require("nvim-dap-virtual-text").setup()
|
|||
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
vim.cmd([[colorscheme gruvbox]])
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
null_ls.setup({
|
||||
debug = false,
|
||||
sources = {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.diagnostics.eslint,
|
||||
null_ls.builtins.completion.spell,
|
||||
},
|
||||
-- 保存自动格式化
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
vim.lsp.buf.format({bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -37,11 +37,7 @@ return require('packer').startup(function()
|
|||
use {
|
||||
"ahmedkhalf/project.nvim",
|
||||
config = function()
|
||||
require("project_nvim").setup {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
}
|
||||
require("project_nvim").setup{}
|
||||
end
|
||||
}
|
||||
-- 空白缩进
|
||||
|
@ -51,17 +47,14 @@ return require('packer').startup(function()
|
|||
-- 终端管理
|
||||
use {"akinsho/toggleterm.nvim", tag = '*', config = function()
|
||||
require("toggleterm").setup()
|
||||
end}
|
||||
end
|
||||
}
|
||||
-- TODO管理
|
||||
use {
|
||||
"folke/todo-comments.nvim",
|
||||
requires = "nvim-lua/plenary.nvim",
|
||||
config = function()
|
||||
require("todo-comments").setup {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
}
|
||||
require("todo-comments").setup{}
|
||||
end
|
||||
}
|
||||
-- git 管理
|
||||
|
@ -82,4 +75,6 @@ return require('packer').startup(function()
|
|||
'nvim-telescope/telescope.nvim', tag = '0.1.1',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
-- lua 代码格式化
|
||||
use({ "jose-elias-alvarez/null-ls.nvim", requires = "nvim-lua/plenary.nvim" })
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue