From c85dbc09a8fa6d17f5bcf708b8a73d09f16070ce Mon Sep 17 00:00:00 2001 From: c-my Date: Fri, 15 Apr 2022 16:04:43 +0800 Subject: [PATCH] conf: format lua files --- lua/configs/keymaps.lua | 2 -- lua/configs/options.lua | 1 - lua/configs/plugins/autopairs.lua | 1 - lua/configs/plugins/better_escape.lua | 3 +-- lua/configs/plugins/bufferline.lua | 2 +- lua/configs/plugins/cmp.lua | 32 +++++++++++++------------- lua/configs/plugins/gitsigns.lua | 1 - lua/configs/plugins/lsp_installer.lua | 2 -- lua/configs/plugins/null_ls.lua | 11 +++++++++ lua/configs/plugins/nvimtree.lua | 2 +- lua/configs/plugins/packer.lua | 33 +++++++++++++++------------ 11 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 lua/configs/plugins/null_ls.lua diff --git a/lua/configs/keymaps.lua b/lua/configs/keymaps.lua index 183ba0c..4ec8e40 100644 --- a/lua/configs/keymaps.lua +++ b/lua/configs/keymaps.lua @@ -41,5 +41,3 @@ vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()lua vim.diagnostic.goto_prev()', opts) vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) - - diff --git a/lua/configs/options.lua b/lua/configs/options.lua index d460301..5a36a73 100644 --- a/lua/configs/options.lua +++ b/lua/configs/options.lua @@ -26,4 +26,3 @@ vim.opt.splitbelow = true vim.opt.splitright = true vim.opt.completeopt = 'menu,menuone,noinsert' - diff --git a/lua/configs/plugins/autopairs.lua b/lua/configs/plugins/autopairs.lua index ef656ec..1c7ece3 100644 --- a/lua/configs/plugins/autopairs.lua +++ b/lua/configs/plugins/autopairs.lua @@ -1,5 +1,4 @@ local present, autopairs = pcall(require, "nvim-autopairs") - if not present then return end diff --git a/lua/configs/plugins/better_escape.lua b/lua/configs/plugins/better_escape.lua index 0500035..6d5c19a 100644 --- a/lua/configs/plugins/better_escape.lua +++ b/lua/configs/plugins/better_escape.lua @@ -1,10 +1,9 @@ local present, escape = pcall(require, 'better_escape') - if not present then print "no escape" return end escape.setup({ - mapping = {'jk'}, + mapping = { 'jk' }, }) diff --git a/lua/configs/plugins/bufferline.lua b/lua/configs/plugins/bufferline.lua index 68a37cc..8e546c8 100644 --- a/lua/configs/plugins/bufferline.lua +++ b/lua/configs/plugins/bufferline.lua @@ -14,6 +14,6 @@ vim.api.nvim_set_keymap('n', '', ':BufferLineCyclePrev', opts) bufferline.setup({ offsets = { - { filetype='NvimTree', text='File Explorer', text_align = 'center' }, + { filetype = 'NvimTree', text = 'File Explorer', text_align = 'center' }, } }) diff --git a/lua/configs/plugins/cmp.lua b/lua/configs/plugins/cmp.lua index 1a6c031..35c78b7 100644 --- a/lua/configs/plugins/cmp.lua +++ b/lua/configs/plugins/cmp.lua @@ -45,7 +45,7 @@ local kind_icons = { TypeParameter = "" } -cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) +cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) cmp.setup({ snippet = { @@ -59,7 +59,7 @@ cmp.setup({ end }, formatting = { - fields = {'kind', 'abbr', 'menu'}, + fields = { 'kind', 'abbr', 'menu' }, format = function(entry, vim_item) vim_item.abbr = string.format('%s', vim_item.abbr) vim_item.kind = string.format('%s', kind_icons[vim_item.kind]) @@ -84,7 +84,7 @@ cmp.setup({ else fallback() end - end, {'i', 'c', 's'}), + end, { 'i', 'c', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item({ @@ -93,21 +93,21 @@ cmp.setup({ else fallback() end - end, {'i', 'c', 's'}), + end, { 'i', 'c', 's' }), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping(cmp.mapping.complete(), {'i', 'c', 's'}), -- d + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), -- d [''] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close() }), - [''] = cmp.mapping(function (fallback) + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.confirm() else fallback() end - end, {'i', 's'}), + end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.confirm({ @@ -118,14 +118,14 @@ cmp.setup({ else fallback() end - end, {'i', 'c', 's'}), + end, { 'i', 'c', 's' }), [''] = cmp.mapping(function(fallback) if luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end - end, {'i', 's'}) + end, { 'i', 's' }) }, completion = { -- Highlight first item @@ -133,13 +133,13 @@ cmp.setup({ }, window = { documentation = { - border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, } }, experimental = { -- ghost_text = true }, - sources = {{ + sources = { { name = 'nvim_lsp' }, { name = 'luasnip' @@ -149,17 +149,17 @@ cmp.setup({ name = 'path' }, { name = 'cmdline' - }} + } } }) cmp.setup.cmdline(':', { - sources = {{ + sources = { { name = 'cmdline' - }} + } } }) cmp.setup.cmdline('/', { - sources = {{ + sources = { { name = 'buffer' - }} + } } }) diff --git a/lua/configs/plugins/gitsigns.lua b/lua/configs/plugins/gitsigns.lua index 51b2d25..557ce68 100644 --- a/lua/configs/plugins/gitsigns.lua +++ b/lua/configs/plugins/gitsigns.lua @@ -1,5 +1,4 @@ local present, gitsigns = pcall(require, "gitsigns") - if not present then print "no gitsigns" return diff --git a/lua/configs/plugins/lsp_installer.lua b/lua/configs/plugins/lsp_installer.lua index b2fcd41..31c0ab2 100644 --- a/lua/configs/plugins/lsp_installer.lua +++ b/lua/configs/plugins/lsp_installer.lua @@ -1,5 +1,4 @@ local present, lsp_installer = pcall(require, 'nvim-lsp-installer') - if not present then print 'no lsp installer' return @@ -69,4 +68,3 @@ lsp_installer.settings({ } } }) - diff --git a/lua/configs/plugins/null_ls.lua b/lua/configs/plugins/null_ls.lua new file mode 100644 index 0000000..6340926 --- /dev/null +++ b/lua/configs/plugins/null_ls.lua @@ -0,0 +1,11 @@ +local present, null_ls = pcall(require, 'null-ls') +if not present then + vim.notify('no null-ls') + return +end + +null_ls.setup({ + sources = { + -- null_ls.builtins.formatting.stylua, + } +}) diff --git a/lua/configs/plugins/nvimtree.lua b/lua/configs/plugins/nvimtree.lua index 103fadc..1644214 100644 --- a/lua/configs/plugins/nvimtree.lua +++ b/lua/configs/plugins/nvimtree.lua @@ -9,7 +9,7 @@ nvimtree.setup({ open_on_setup = true, open_on_setup_file = true, open_on_tab = true, - ignore_ft_on_setup = {'alpha', 'dashboard'}, + ignore_ft_on_setup = { 'alpha', 'dashboard' }, diagnostics = { enable = true, show_on_dirs = false, diff --git a/lua/configs/plugins/packer.lua b/lua/configs/plugins/packer.lua index b14bcdc..c42a64c 100644 --- a/lua/configs/plugins/packer.lua +++ b/lua/configs/plugins/packer.lua @@ -1,8 +1,8 @@ local fn = vim.fn local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', - install_path}) + packer_bootstrap = fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', + install_path }) end -- Only required if you have packer configured as `opt` @@ -34,14 +34,14 @@ return packer.startup(function(use) } use { 'numToStr/Comment.nvim', - event = {'BufRead', 'BufNewFile'}, + event = { 'BufRead', 'BufNewFile' }, config = function() require('configs.plugins.comment') end } use { 'lewis6991/gitsigns.nvim', - event = {'BufRead', 'BufNewFile'}, + event = { 'BufRead', 'BufNewFile' }, config = function() require('configs.plugins.gitsigns') end @@ -62,15 +62,15 @@ return packer.startup(function(use) require('configs.plugins.cmp') end } - use {'hrsh7th/cmp-nvim-lsp'} - use {'hrsh7th/cmp-buffer'} - use {'hrsh7th/cmp-path'} - use {'hrsh7th/cmp-cmdline'} - use {'saadparwaiz1/cmp_luasnip'} -- Snippet compleetions + use { 'hrsh7th/cmp-nvim-lsp' } + use { 'hrsh7th/cmp-buffer' } + use { 'hrsh7th/cmp-path' } + use { 'hrsh7th/cmp-cmdline' } + use { 'saadparwaiz1/cmp_luasnip' } -- Snippet compleetions -- Snippets - use {'L3MON4D3/LuaSnip'} -- Snippet engine - use {'rafamadriz/friendly-snippets'} -- Snippets collection + use { 'L3MON4D3/LuaSnip' } -- Snippet engine + use { 'rafamadriz/friendly-snippets' } -- Snippets collection -- LSP use { @@ -85,12 +85,17 @@ return packer.startup(function(use) require('configs.plugins.lsp_installer') end } + -- use { 'jose-elias-alvarez/null-ls.nvim', + -- config = function() + -- require('configs.plugins.null_ls') + -- end + -- } -- UI Plugins - use {'kyazdani42/nvim-web-devicons'} + use { 'kyazdani42/nvim-web-devicons' } use { 'kyazdani42/nvim-tree.lua', - requires = {'kyazdani42/nvim-web-devicons' -- optional, for file icon + requires = { 'kyazdani42/nvim-web-devicons' -- optional, for file icon }, config = function() require('configs.plugins.nvimtree') @@ -99,7 +104,7 @@ return packer.startup(function(use) use { 'nvim-telescope/telescope.nvim', cmd = 'Telescope', - requires = {{'nvim-lua/plenary.nvim'}} + requires = { { 'nvim-lua/plenary.nvim' } } } use { 'akinsho/bufferline.nvim',