Added null-ls plugin.This enables certain tools to act as LSPs
(formatters, linters, etc)
This commit is contained in:
parent
0baee67ded
commit
13b0b340f9
3 changed files with 69 additions and 46 deletions
|
@ -1,12 +1,11 @@
|
|||
|
||||
local mason_lspconfig = require "mason-lspconfig"
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = { "sumneko_lua", "rust_analyzer" , "texlab", "hls"},
|
||||
automatic_installation = true
|
||||
ensure_installed = { "sumneko_lua", "rust_analyzer", "texlab", "hls", "yamlls" },
|
||||
automatic_installation = true
|
||||
})
|
||||
|
||||
local opts = { noremap=true, silent=true }
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
|
@ -20,7 +19,7 @@ local on_attach = function(client, bufnr)
|
|||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
|
@ -30,29 +29,32 @@ local on_attach = function(client, bufnr)
|
|||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
end, bufopts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>ge', function () vim.diagnostic.goto_next() end, bufopts)
|
||||
vim.keymap.set('n', '<space>gE', function () vim.diagnostic.goto_prev() end, bufopts)
|
||||
vim.keymap.set('n', '<space>ge', function() vim.diagnostic.goto_next() end, bufopts)
|
||||
vim.keymap.set('n', '<space>gE', function() vim.diagnostic.goto_prev() end, bufopts)
|
||||
vim.keymap.set('n', '<space>fo', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||
-- vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
-- pattern = '<buffer>',
|
||||
-- callback = function() vim.lsp.buf.format({ async = true }) end
|
||||
-- })
|
||||
if client.name == "yamlls" then
|
||||
client.server_capabilities.document_formatting = true
|
||||
end
|
||||
end
|
||||
|
||||
local lspconfig = require "lspconfig"
|
||||
|
||||
mason_lspconfig.setup_handlers {
|
||||
|
||||
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
|
||||
function (server_name)
|
||||
lspconfig[server_name].setup {
|
||||
on_attach = on_attach,
|
||||
flags = lsp_flags,
|
||||
}
|
||||
end,
|
||||
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup {
|
||||
on_attach = on_attach,
|
||||
flags = lsp_flags,
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
|
10
.config/nvim/lua/plugins/null-ls.lua
Normal file
10
.config/nvim/lua/plugins/null-ls.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.rustfmt,
|
||||
null_ls.builtins.formatting.prettierd.with({
|
||||
filetypes = { "html", "json", "yaml", "markdown" },
|
||||
}),
|
||||
}
|
||||
})
|
|
@ -1,62 +1,73 @@
|
|||
|
||||
local packer = require("packer")
|
||||
|
||||
local plugins = packer.startup({function(use)
|
||||
local plugins = packer.startup({ function(use)
|
||||
|
||||
use {
|
||||
"wbthomason/packer.nvim",
|
||||
config = [[require("plugins.packer")]]
|
||||
}
|
||||
|
||||
use{ "lewis6991/impatient.nvim"}
|
||||
use { "lewis6991/impatient.nvim" }
|
||||
|
||||
|
||||
use{ "lervag/vimtex",
|
||||
config = function ()
|
||||
use { "lervag/vimtex",
|
||||
config = function()
|
||||
require "plugins.vimtex"
|
||||
end
|
||||
}
|
||||
|
||||
-------------------------------------------------------QOL----------------------------------------------
|
||||
|
||||
use { "ggandor/leap.nvim",
|
||||
config = function ()
|
||||
use { "ggandor/leap.nvim",
|
||||
config = function()
|
||||
require('leap').add_default_mappings()
|
||||
end
|
||||
}
|
||||
|
||||
use {'stevearc/dressing.nvim'} -- Rename variable pop up
|
||||
use { 'stevearc/dressing.nvim' } -- Rename variable pop up
|
||||
|
||||
use {"windwp/nvim-autopairs",
|
||||
use { "windwp/nvim-autopairs",
|
||||
config = function() require("nvim-autopairs").setup {}
|
||||
end
|
||||
}
|
||||
|
||||
use {'kyazdani42/nvim-web-devicons'}
|
||||
use { 'kyazdani42/nvim-web-devicons' }
|
||||
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
||||
config = function ()
|
||||
config = function()
|
||||
require 'plugins.lualine'
|
||||
end
|
||||
}
|
||||
|
||||
use { 'rcarriga/nvim-notify',
|
||||
config = function()
|
||||
vim.notify = require("notify")
|
||||
end
|
||||
}
|
||||
-------------------------------------------------------LSP----------------------------------------------
|
||||
|
||||
use { "williamboman/mason.nvim",
|
||||
config = function ()
|
||||
use { "williamboman/mason.nvim",
|
||||
config = function()
|
||||
require "plugins.mason"
|
||||
end
|
||||
}
|
||||
|
||||
use {"williamboman/mason-lspconfig.nvim"}
|
||||
use { "williamboman/mason-lspconfig.nvim" }
|
||||
|
||||
use { "neovim/nvim-lspconfig",
|
||||
config = function ()
|
||||
use { "neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
require "plugins.lspconfig"
|
||||
end
|
||||
}
|
||||
|
||||
use { "jose-elias-alvarez/null-ls.nvim",
|
||||
config = function()
|
||||
require "plugins.null-ls"
|
||||
end
|
||||
}
|
||||
|
||||
use { "L3MON4D3/LuaSnip",
|
||||
requires = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
|
@ -77,7 +88,7 @@ local plugins = packer.startup({function(use)
|
|||
}
|
||||
|
||||
|
||||
use {'nvim-tree/nvim-tree.lua',
|
||||
use { 'nvim-tree/nvim-tree.lua',
|
||||
requires = {
|
||||
'nvim-tree/nvim-web-devicons', -- optional, for file icons
|
||||
},
|
||||
|
@ -85,28 +96,28 @@ local plugins = packer.startup({function(use)
|
|||
require("nvim-tree").setup()
|
||||
end
|
||||
}
|
||||
use { "feline-nvim/feline.nvim" }
|
||||
use { "feline-nvim/feline.nvim" }
|
||||
-------------------------------------------THEMES------------------------------------------
|
||||
|
||||
use {"joshdick/onedark.vim" }
|
||||
use {"catppuccin/nvim"}
|
||||
use { "joshdick/onedark.vim" }
|
||||
use { "catppuccin/nvim" }
|
||||
-------------------------------------------------------------------------------------------
|
||||
use {"nvim-treesitter/nvim-treesitter",
|
||||
use { "nvim-treesitter/nvim-treesitter",
|
||||
config = function()
|
||||
require "plugins.treesitter"
|
||||
end
|
||||
}
|
||||
|
||||
use {"nvim-treesitter/nvim-treesitter-context",
|
||||
use { "nvim-treesitter/nvim-treesitter-context",
|
||||
config = function()
|
||||
require "plugins.treesitter-context"
|
||||
end
|
||||
}
|
||||
|
||||
--Tabs
|
||||
use {'romgrk/barbar.nvim',
|
||||
use { 'romgrk/barbar.nvim',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
config = function ()
|
||||
config = function()
|
||||
require "plugins.barbar"
|
||||
end
|
||||
}
|
||||
|
@ -115,20 +126,20 @@ local plugins = packer.startup({function(use)
|
|||
use {
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.0',
|
||||
-- or , branch = '0.1.x',
|
||||
requires = { {'nvim-lua/plenary.nvim'} },
|
||||
requires = { { 'nvim-lua/plenary.nvim' } },
|
||||
config = function() require('plugins.telescope') end
|
||||
}
|
||||
|
||||
use {"tpope/vim-surround"}
|
||||
use { "tpope/vim-surround" }
|
||||
|
||||
use {"startup-nvim/startup.nvim",
|
||||
requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"},
|
||||
use { "startup-nvim/startup.nvim",
|
||||
requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
require("startup").setup { theme = "dashboard" }
|
||||
end,
|
||||
}
|
||||
|
||||
end,
|
||||
end,
|
||||
|
||||
config = {
|
||||
auto_clean = true,
|
||||
|
|
Loading…
Reference in a new issue