null-ls functionality

This commit is contained in:
juan 2023-03-09 17:25:09 +08:00
parent 43456e196f
commit 7223a95766
Signed by: juan
GPG Key ID: 5C1E5093C74F1DC7
6 changed files with 33 additions and 43 deletions

View File

@ -56,8 +56,5 @@ map('', '<leader>w', ':HopWordAC<cr>', { silent = true })
map('', '<leader>l', ':HopWordCurrentLine<cr>', { silent = true }) map('', '<leader>l', ':HopWordCurrentLine<cr>', { silent = true })
-- telescope stuff -- telescope stuff
map('', '<leader>fd', ':Telescope fd<cr>', map('', '<leader>fd', ':Telescope fd<cr>', { silent = true })
{ silent = true })
map('', '<leader>tb', ':Telescope buffers<cr>', { silent = true }) map('', '<leader>tb', ':Telescope buffers<cr>', { silent = true })

View File

@ -25,7 +25,7 @@ return require('packer').startup(function(use)
-- lsp stuff -- lsp stuff
use { use {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
after = "mason-lspconfig.nvim", after = { "mason-lspconfig.nvim", "null-ls.nvim" },
config = function() require 'plugins.lsp' end config = function() require 'plugins.lsp' end
} }
use { 'williamboman/mason-lspconfig.nvim', after = 'mason.nvim' } 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 { 'hrsh7th/cmp-nvim-lsp-document-symbol', after = 'nvim-cmp' }, -- TS
{ 'ray-x/cmp-treesitter', after = 'nvim-cmp' }, -- end { 'ray-x/cmp-treesitter', after = 'nvim-cmp' }, -- end
-- Snip -- 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 { use {
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
config = function()
require('plugins.null-ls')
end,
requires = { "nvim-lua/plenary.nvim" }, 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 { use {
'mattn/emmet-vim', 'mattn/emmet-vim',
@ -106,11 +110,6 @@ return require('packer').startup(function(use)
after = 'nvim-treesitter', after = 'nvim-treesitter',
config = function() require 'plugins.matchup' end 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 { use {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
event = 'UIEnter', event = 'UIEnter',

View File

@ -21,7 +21,7 @@ cmp.setup({
end, end,
}, },
mapping = { mapping = {
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
@ -34,7 +34,7 @@ cmp.setup({
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
@ -43,11 +43,11 @@ cmp.setup({
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(), ['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items
-- ... Your other mappings ... -- ... Your other mappings ...
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({

View File

@ -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 require 'mason-null-ls'.setup_handlers() -- If `automatic_setup` is true.
-- 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 })

View File

@ -2,7 +2,7 @@ local npairs = require('nvim-autopairs')
npairs.setup({map_bs = true, map_cr = true, map_c_w = true}) npairs.setup({map_bs = true, map_cr = true, map_c_w = true})
-- If you want insert `(` after select function or method item -- -- If you want insert `(` after select function or method item
local cmp_autopairs = require('nvim-autopairs.completion.cmp') -- local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp') -- local cmp = require('cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) -- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())

View File