]> git.huck.website - nvim.git/commitdiff
update: mason - null ls - lsp config better integration
authorHuck Boles <huck@huck.website>
Tue, 16 May 2023 16:56:43 +0000 (11:56 -0500)
committerHuck Boles <huck@huck.website>
Tue, 16 May 2023 16:56:43 +0000 (11:56 -0500)
lua/huck/functions.lua
lua/huck/map.lua
lua/plugins/cmp.lua
lua/plugins/lsp.lua
lua/plugins/lualine.lua

index dc2fa628b408b56890a5e237911089df9a780e59..cbf591537a712ccb52c814d1c87446d3c3a022c9 100644 (file)
@@ -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,
 })
index 00dd39b32cac2761510e4fb5b0a6401f4e24ffd0..339edd7517ac8731eb033b675839963c4ed501ce 100644 (file)
@@ -19,6 +19,8 @@ vim.keymap.set('n', '<LEADER>c', ':r!')
 vim.keymap.set('n', '<LEADER>h', ":vsplit ")
 vim.keymap.set('n', '<LEADER>v', ":split ")
 vim.keymap.set('n', '<LEADER>t', ':tabnew ')
+vim.keymap.set('n', '<LEADER>-', ':set filetype=')
+vim.keymap.set('n', '<LEADER>_', '<CMD>setlocal spell spelllang=en_us<CR>')
 
 -- better line editing
 vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
index 15a5cc20acebad5300b502c0675eb3fa5f0304db..d60d6dcd6b44485ea18d3d4c558d5e3a75beb34e 100644 (file)
@@ -23,8 +23,10 @@ return {
                     ['<C-b>'] = cmp.mapping.scroll_docs(-4),
                     ['<C-f>'] = cmp.mapping.scroll_docs(4),
                     ['<TAB>'] = cmp.mapping.complete(),
-                    ['<C-c>'] = cmp.mapping.abort(),
                     ['<TAB>'] = cmp.mapping.confirm({ select = true }),
+                    ['<C-c>'] = cmp.mapping.abort(),
+                    ['<C-j>'] = cmp.mapping.select_next_item(),
+                    ['<C-k>'] = cmp.mapping.select_prev_item(),
                 }),
                 sources = cmp.config.sources({
                     { name = 'nvim_lsp' },
index a9226d0464f12c92fb7222d77e77c2f0699c2c24..1f851051609ca1de6b1dc2448551146648c8d549 100644 (file)
 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,
     },
-
 }
index 7b29d9f50f453536c21598bd3959e5013d53137c..a9fae7054c1a94ef2d6e051d57d5d9fd474c3366 100644 (file)
@@ -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 = {},
+    },
 }