From: Huck Boles Date: Tue, 16 May 2023 16:56:43 +0000 (-0500) Subject: update: mason - null ls - lsp config better integration X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=31f73c9c97784cf17bf78d8ca0cc4e7683837df0;p=nvim.git update: mason - null ls - lsp config better integration --- diff --git a/lua/huck/functions.lua b/lua/huck/functions.lua index dc2fa62..cbf5915 100644 --- a/lua/huck/functions.lua +++ b/lua/huck/functions.lua @@ -3,39 +3,39 @@ vim.api.nvim_create_autocmd("BufWinEnter", { pattern = { "*" }, callback = function() local filetype = vim.o.filetype - if filetype == 'help' or filetype == 'fugitive' or filetype == 'gitcommit' then + if filetype == "help" or filetype == "fugitive" or filetype == "gitcommit" then vim.cmd.wincmd("L") end - end + end, }) -- check template folder and if a template.[filetype] exists use it vim.api.nvim_create_autocmd("BufNewFile", { pattern = { "*" }, callback = function() - local ext = vim.fn.expand('%:e') - local filename = vim.fn.expand('%:t') - local dir = '/home/huck/repos/templates/' + local ext = vim.fn.expand("%:e") + local filename = vim.fn.expand("%:t") + local dir = "/home/huck/repos/templates/" local copy = function(name) local path = dir .. name .. ext if vim.fn.filereadable(path) == 1 then - vim.cmd('0r ' .. path) + vim.cmd("0r " .. path) end end - if ext ~= '' then - copy('template.') - elseif filename == 'Makefile' or 'LICENSE' then + if ext ~= "" then + copy("template.") + elseif filename == "Makefile" or "LICENSE" then copy(filename) end - end + end, }) -- auto format code on save -vim.api.nvim_create_autocmd('BufWritePre', { +vim.api.nvim_create_autocmd("BufWritePre", { pattern = { "*" }, callback = function() vim.lsp.buf.format() - end + end, }) diff --git a/lua/huck/map.lua b/lua/huck/map.lua index 00dd39b..339edd7 100644 --- a/lua/huck/map.lua +++ b/lua/huck/map.lua @@ -19,6 +19,8 @@ vim.keymap.set('n', 'c', ':r!') vim.keymap.set('n', 'h', ":vsplit ") vim.keymap.set('n', 'v', ":split ") vim.keymap.set('n', 't', ':tabnew ') +vim.keymap.set('n', '-', ':set filetype=') +vim.keymap.set('n', '_', 'setlocal spell spelllang=en_us') -- better line editing vim.keymap.set('v', 'J', ":m '>+1gv=gv") diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 15a5cc2..d60d6dc 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -23,8 +23,10 @@ return { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index a9226d0..1f85105 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,47 +1,100 @@ return { { - 'neovim/nvim-lspconfig', - -- event = { 'BufReadPre', 'BufNewFile' }, - lazy = false, + "jose-elias-alvarez/null-ls.nvim", dependencies = { - 'nvim-cmp', - 'nvim-treesitter', - 'Maan2003/lsp_lines.nvim', - { 'williamboman/mason.nvim', build = ':MasonUpdate' }, - { 'williamboman/mason-lspconfig', version = '1.3.0' }, + "plenary.nvim", + { + "jay-babu/mason-null-ls.nvim", + dependencies = { "mason.nvim" }, + config = function() + local mason_null = function(source_name, methods) + require("mason-null-ls").default_setup(source_name, methods) + end + + require("mason-null-ls").setup({ + automatic_installation = true, + handlers = { + function() + end, + proselint = mason_null, + codespell = mason_null, + shellcheck = mason_null, + write_good = mason_null, + shellharden = mason_null, + }, + }) + end, + }, }, config = function() - require('mason').setup() + local null_ls = require("null-ls") + local diagnostics = null_ls.builtins.diagnostics + local formatting = null_ls.builtins.formatting + local hover = null_ls.builtins.hover + local completion = null_ls.builtins.completion - require('mason-lspconfig').setup({ - automatic_installation = true, - ensure_installed = { 'rust_analyzer' } + require("null-ls").setup({ + sources = { + completion.spell, + diagnostics.todo_comments, + diagnostics.trail_space, + formatting.trim_whitespace, + formatting.trim_newlines, + hover.dictionary, + hover.printenv, + }, }) + end, + }, - local handlers = { - function(server_name) - require("lspconfig")[server_name].setup({}) + { + "williamboman/mason-lspconfig", + dependencies = { + { + "williamboman/mason.nvim", + build = ":MasonUpdate", + config = function() + require("mason").setup() end, - } - - require('mason-lspconfig').setup_handlers(handlers) - - -- docker_compose_language_service, jsonls, marksman, yamlls, awk_ls, solargraph, bashls, dockerls, clangd, lua_ls, vimls, rust_analyzer, html, cssls + }, + }, + version = "1.3.0", + config = function() + require("mason-lspconfig").setup({ + automatic_installation = true, + ensure_installed = { "rust_analyzer", "clangd", "lua_ls", "solargraph" }, + }) + end, + }, - -- require('lspconfig').docker_compose_language_service.setup({}) - -- require('lspconfig').jsonls.setup({}) - -- require('lspconfig').marksman.setup({}) - -- require('lspconfig').yamlls.setup({}) - -- require('lspconfig').awk_ls.setup({}) - -- require('lspconfig').solargraph.setup({}) - -- require('lspconfig').bashls.setup({}) - -- require('lspconfig').dockerls.setup({}) - -- require('lspconfig').clangd.setup({}) - -- require('lspconfig').lua_ls.setup({}) - -- require('lspconfig').vimls.setup({}) - -- require('lspconfig').rust_analyzer.setup({}) - -- require('lspconfig').html.setup({}) - -- require('lspconfig').cssls.setup({}) + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + lazy = false, + dependencies = { + "mason-lspconfig", + "nvim-cmp", + "nvim-treesitter", + "null-ls.nvim", + "Maan2003/lsp_lines.nvim", + }, + config = function() + local lsp = require("lspconfig") + lsp.awk_ls.setup({}) + lsp.bashls.setup({}) + lsp.clangd.setup({}) + lsp.cssls.setup({}) + lsp.dockerls.setup({}) + lsp.docker_compose_language_service.setup({}) + lsp.html.setup({}) + lsp.jsonls.setup({}) + lsp.lua_ls.setup({}) + lsp.marksman.setup({}) + lsp.solargraph.setup({}) + -- lsp.sorbet.setup({}) + lsp.rust_analyzer.setup({}) + lsp.taplo.setup({}) + lsp.yamlls.setup({}) local border = { { "┏", "FloatBorder" }, @@ -58,7 +111,7 @@ return { signs = true, underline = true, update_in_insert = false, - severity_sort = { reverse = true }, + severity_sort = { reverse = false }, } local signs = { Error = ">>", Warn = "> ", Hint = "- ", Info = " " } @@ -73,24 +126,6 @@ return { opts.border = opts.border or border return orig_util_open_floating_preview(contents, syntax, opts, ...) end - end - }, - - { - 'jay-babu/mason-null-ls.nvim', - lazy = { 'BufReadPre', 'BufNewFile' }, - dependencies = { - 'mason.nvim', - { - 'jose-elias-alvarez/null-ls.nvim', - dependencies = { 'plenary.nvim' }, - } - }, - config = function() - require('mason-null-ls').setup({ - automatic_setup = true, - }) - end + end, }, - } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 7b29d9f..a9fae70 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,12 +1,12 @@ return { - 'nvim-lualine/lualine.nvim', + "nvim-lualine/lualine.nvim", lazy = false, opts = { options = { icons_enabled = true, - theme = 'auto', - component_separators = { left = '|', right = '|' }, - section_separators = { left = '', right = '' }, + theme = "auto", + component_separators = { left = "|", right = "|" }, + section_separators = { left = "", right = "" }, disabled_filetypes = { statusline = {}, winbar = {}, @@ -18,48 +18,48 @@ return { statusline = 1000, tabline = 1000, winbar = 1000, - } + }, }, sections = { - lualine_a = { 'mode' }, - lualine_b = { { 'filename', path = 3 } }, - lualine_c = { 'git', 'branch', 'diff' }, - lualine_x = { 'encoding' }, - lualine_y = { 'diagnostics' }, - lualine_z = { 'location', 'progress' } + lualine_a = { "mode" }, + lualine_b = { { "filename", path = 3 } }, + lualine_c = { "git", "branch", "diff" }, + lualine_x = { "encoding" }, + lualine_y = { "diagnostics" }, + lualine_z = { "location", "progress" }, }, inactive_sections = { - lualine_a = { 'filename' }, - lualine_b = { { 'filename', path = 3 } }, + lualine_a = { "filename" }, + lualine_b = { { "filename", path = 3 } }, lualine_c = {}, lualine_x = {}, lualine_y = {}, - lualine_z = { 'location' } + lualine_z = { "location" }, }, winbar = { - lualine_a = { 'filename', 'filesize', 'filetype' }, + lualine_a = { "filename", "filesize", "filetype" }, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, lualine_z = { { - 'tabs', + "tabs", tabs_color = { - active = 'StatusLine', - inactive = 'StatusLineNC', + active = "StatusLine", + inactive = "StatusLineNC", }, - } - } + }, + }, }, inactive_winbar = { - lualine_a = { 'filename' }, + lualine_a = { "filename" }, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, - lualine_z = { 'ObsessionStatus' } + lualine_z = { "ObsessionStatus" }, }, - extensions = {} - } + extensions = {}, + }, }