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>3', ':BufferLineGoToBuffer 3<CR>', opt)
|
||||||
map('n', '<leader>4', ':BufferLineGoToBuffer 4<CR>', opt)
|
map('n', '<leader>4', ':BufferLineGoToBuffer 4<CR>', opt)
|
||||||
map('n', '<leader>5', ':BufferLineGoToBuffer 5<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.o.background = "dark" -- or "light" for light mode
|
||||||
vim.cmd([[colorscheme gruvbox]])
|
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,
|
||||||
|
})
|
||||||
|
|
117
lua/plugins.lua
117
lua/plugins.lua
|
@ -1,22 +1,22 @@
|
||||||
return require('packer').startup(function()
|
return require('packer').startup(function()
|
||||||
-- Packer can manage itself
|
-- Packer can manage itself
|
||||||
use 'wbthomason/packer.nvim'
|
use 'wbthomason/packer.nvim'
|
||||||
-- 文件树
|
-- 文件树
|
||||||
use {
|
use {
|
||||||
'nvim-tree/nvim-tree.lua',
|
'nvim-tree/nvim-tree.lua',
|
||||||
requires = {
|
requires = {
|
||||||
'nvim-tree/nvim-web-devicons', -- optional, for file icons
|
'nvim-tree/nvim-web-devicons', -- optional, for file icons
|
||||||
},
|
},
|
||||||
tag = 'nightly' -- optional, updated every week. (see issue #1193)
|
tag = 'nightly' -- optional, updated every week. (see issue #1193)
|
||||||
}
|
}
|
||||||
-- 欢迎页
|
-- 欢迎页
|
||||||
use {
|
use {
|
||||||
'goolord/alpha-nvim',
|
'goolord/alpha-nvim',
|
||||||
requires = { 'nvim-tree/nvim-web-devicons' },
|
requires = { 'nvim-tree/nvim-web-devicons' },
|
||||||
config = function ()
|
config = function ()
|
||||||
require'alpha'.setup(require'alpha.themes.startify'.config)
|
require'alpha'.setup(require'alpha.themes.startify'.config)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
-- 主题
|
-- 主题
|
||||||
use { "ellisonleao/gruvbox.nvim" }
|
use { "ellisonleao/gruvbox.nvim" }
|
||||||
-- 代码缩略图
|
-- 代码缩略图
|
||||||
|
@ -35,51 +35,46 @@ return require('packer').startup(function()
|
||||||
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
|
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
|
||||||
-- 当前工作目录
|
-- 当前工作目录
|
||||||
use {
|
use {
|
||||||
"ahmedkhalf/project.nvim",
|
"ahmedkhalf/project.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("project_nvim").setup {
|
require("project_nvim").setup{}
|
||||||
-- your configuration comes here
|
end
|
||||||
-- or leave it empty to use the default settings
|
|
||||||
-- refer to the configuration section below
|
|
||||||
}
|
}
|
||||||
end
|
-- 空白缩进
|
||||||
}
|
use "lukas-reineke/indent-blankline.nvim"
|
||||||
-- 空白缩进
|
-- 改善启动时间
|
||||||
use "lukas-reineke/indent-blankline.nvim"
|
use 'lewis6991/impatient.nvim'
|
||||||
-- 改善启动时间
|
-- 终端管理
|
||||||
use 'lewis6991/impatient.nvim'
|
use {"akinsho/toggleterm.nvim", tag = '*', config = function()
|
||||||
-- 终端管理
|
require("toggleterm").setup()
|
||||||
use {"akinsho/toggleterm.nvim", tag = '*', config = function()
|
end
|
||||||
require("toggleterm").setup()
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
end
|
-- TODO管理
|
||||||
}
|
use {
|
||||||
-- git 管理
|
"folke/todo-comments.nvim",
|
||||||
use {
|
requires = "nvim-lua/plenary.nvim",
|
||||||
'lewis6991/gitsigns.nvim',
|
config = function()
|
||||||
}
|
require("todo-comments").setup{}
|
||||||
-- 注释管理
|
end
|
||||||
use {
|
}
|
||||||
'numToStr/Comment.nvim',
|
-- git 管理
|
||||||
config = function()
|
use {
|
||||||
require('Comment').setup()
|
'lewis6991/gitsigns.nvim',
|
||||||
end
|
}
|
||||||
}
|
-- 注释管理
|
||||||
-- coc 代码提示
|
use {
|
||||||
use {'neoclide/coc.nvim', branch = 'release'}
|
'numToStr/Comment.nvim',
|
||||||
-- 搜索
|
config = function()
|
||||||
use {
|
require('Comment').setup()
|
||||||
'nvim-telescope/telescope.nvim', tag = '0.1.1',
|
end
|
||||||
requires = { {'nvim-lua/plenary.nvim'} }
|
}
|
||||||
}
|
-- coc 代码提示
|
||||||
|
use {'neoclide/coc.nvim', branch = 'release'}
|
||||||
|
-- 搜索
|
||||||
|
use {
|
||||||
|
'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)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue