From 7223a9576684a9cce282017f3cf0ea34fb0fc0f7 Mon Sep 17 00:00:00 2001 From: juan Date: Thu, 9 Mar 2023 17:25:09 +0800 Subject: [PATCH] null-ls functionality --- lua/mappings.lua | 5 +---- lua/plugins.lua | 21 ++++++++++----------- lua/plugins/cmp.lua | 14 +++++++------- lua/plugins/null-ls.lua | 28 +++++++++++----------------- lua/plugins/nvim-autopairs.lua | 8 ++++---- lua/plugins/test.java | 0 6 files changed, 33 insertions(+), 43 deletions(-) delete mode 100644 lua/plugins/test.java diff --git a/lua/mappings.lua b/lua/mappings.lua index 0ba32b3..376481a 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -56,8 +56,5 @@ map('', 'w', ':HopWordAC', { silent = true }) map('', 'l', ':HopWordCurrentLine', { silent = true }) -- telescope stuff -map('', 'fd', ':Telescope fd', - - - { silent = true }) +map('', 'fd', ':Telescope fd', { silent = true }) map('', 'tb', ':Telescope buffers', { silent = true }) diff --git a/lua/plugins.lua b/lua/plugins.lua index f6604a2..56e8615 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -25,7 +25,7 @@ return require('packer').startup(function(use) -- lsp stuff use { 'neovim/nvim-lspconfig', - after = "mason-lspconfig.nvim", + after = { "mason-lspconfig.nvim", "null-ls.nvim" }, config = function() require 'plugins.lsp' end } use { 'williamboman/mason-lspconfig.nvim', after = 'mason.nvim' } @@ -68,7 +68,7 @@ return require('packer').startup(function(use) { 'hrsh7th/cmp-nvim-lsp-document-symbol', after = 'nvim-cmp' }, -- TS { 'ray-x/cmp-treesitter', after = 'nvim-cmp' }, -- end -- Snip - { 'saadparwaiz1/cmp_luasnip', after = { 'nvim-cmp', 'LuaSnip' } } + { 'saadparwaiz1/cmp_luasnip', after = { 'nvim-cmp', 'LuaSnip' } }, } } @@ -81,11 +81,15 @@ return require('packer').startup(function(use) } use { "jose-elias-alvarez/null-ls.nvim", - config = function() - require('plugins.null-ls') - end, requires = { "nvim-lua/plenary.nvim" }, - event = "CmdlineEnter" + event = 'BufEnter' + } + use { + "jay-babu/mason-null-ls.nvim", + config = function() + require 'plugins.null-ls' + end, + after = { "mason.nvim", "null-ls.nvim" } } use { 'mattn/emmet-vim', @@ -106,11 +110,6 @@ return require('packer').startup(function(use) after = 'nvim-treesitter', config = function() require 'plugins.matchup' end } - use { - 'abecodes/tabout.nvim', - config = function() require('tabout').setup {} end, - after = { 'nvim-treesitter', 'nvim-autopairs', 'nvim-cmp' } -- if a completion plugin is using tabs load it before - } use { 'nvim-telescope/telescope.nvim', event = 'UIEnter', diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index f20a3ab..9c883f6 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -21,7 +21,7 @@ cmp.setup({ end, }, mapping = { - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() @@ -34,7 +34,7 @@ cmp.setup({ fallback() end end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then @@ -43,11 +43,11 @@ cmp.setup({ fallback() end end, { "i", "s" }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items -- ... Your other mappings ... }, sources = cmp.config.sources({ diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index 7790227..55f9026 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -1,18 +1,12 @@ -local null_ls = require("null-ls") +require("mason").setup() +require("mason-null-ls").setup({ + automatic_installation = false, + automatic_setup = true, -- Recommended, but optional +}) +require("null-ls").setup({ + sources = { + -- Anything not supported by mason. + } +}) --- builtins --- local code_actions = null_ls.builtins.code_actions -local diagnostics = null_ls.builtins.diagnostics -local formatting = null_ls.builtins.formatting -local hover = null_ls.builtins.hover -local completion = null_ls.builtins.completion - -local sources = { - code_actions, - diagnostics, - formatting, - hover, - completion -} - -null_ls.setup({ sources = sources }) +require 'mason-null-ls'.setup_handlers() -- If `automatic_setup` is true. diff --git a/lua/plugins/nvim-autopairs.lua b/lua/plugins/nvim-autopairs.lua index b48dd9f..19b749a 100644 --- a/lua/plugins/nvim-autopairs.lua +++ b/lua/plugins/nvim-autopairs.lua @@ -2,7 +2,7 @@ local npairs = require('nvim-autopairs') npairs.setup({map_bs = true, map_cr = true, map_c_w = true}) --- If you want insert `(` after select function or method item -local cmp_autopairs = require('nvim-autopairs.completion.cmp') -local cmp = require('cmp') -cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) +-- -- If you want insert `(` after select function or method item +-- local cmp_autopairs = require('nvim-autopairs.completion.cmp') +-- local cmp = require('cmp') +-- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) diff --git a/lua/plugins/test.java b/lua/plugins/test.java deleted file mode 100644 index e69de29..0000000