]> git.huck.website - nvim.git/commitdiff
working mason, lsp, cmp and treesitter
authorHuck Boles <huck@huck.website>
Sun, 16 Apr 2023 16:59:58 +0000 (11:59 -0500)
committerHuck Boles <huck@huck.website>
Sun, 16 Apr 2023 16:59:58 +0000 (11:59 -0500)
lua/function.lua [deleted file]
lua/plugins.lua
lua/plugins/cmp.lua
lua/plugins/lsp.lua
lua/plugins/treesitter.lua [new file with mode: 0644]
lua/settings.lua

diff --git a/lua/function.lua b/lua/function.lua
deleted file mode 100644 (file)
index e69de29..0000000
index 38ac366b66bef0a8dcbba3bb15d41217a1893fa4..309b3ae3659039797be5316438f19359358abe8d 100644 (file)
@@ -1,20 +1,25 @@
 return {
-    'tpope/vim-surround',
-    'tpope/vim-obsession',
-    'tpope/vim-endwise',
-    'tpope/vim-repeat',
-    'tpope/vim-commentary',
-    'junegunn/fzf',
-    'junegunn/fzf.vim',
 
-    'lukas-reineke/indent-blankline.nvim',
-    'christoomey/vim-tmux-navigator',
-    'norcalli/nvim-colorizer.lua',
-    'Maan2003/lsp_lines.nvim',
     'mbbill/undotree',
 
+    { 'christoomey/vim-tmux-navigator', lazy = false },
+    { 'norcalli/nvim-colorizer.lua', lazy = false },
+    { 'lukas-reineke/indent-blankline.nvim', lazy = false },
+    { 'tpope/vim-repeat', lazy = false },
+    { 'tpope/vim-obsession', lazy = false },
+    { 'tpope/vim-surround', lazy = false },
+    { 'tpope/vim-endwise', lazy = false },
+    { 'tpope/vim-commentary', lazy = false },
+
+    { 
+        'junegunn/fzf.vim', 
+        dependencies = {'junegunn/fzf'},
+        lazy = false
+    },
+
     {
         'akinsho/toggleterm.nvim',
+        lazy = false,
         opts = {
             shade_terminals = false,
             size = 10
index 67d105ceac01c625649ea7df2aaceb6d8121ba9d..42bc60e768e3d98e7cf73f8df0fdd23fdab21891 100644 (file)
@@ -1,36 +1,60 @@
 return {
-    { 
-        'hrsh7th/nvim-cmp', 
+    {
+        'hrsh7th/nvim-cmp',
+        version = false,
         dependencies = {
             'onsails/lspkind.nvim',
             'hrsh7th/cmp-nvim-lsp',
             'hrsh7th/cmp-buffer',
             'hrsh7th/cmp-path',
             'hrsh7th/cmp-cmdline',
+            'hrsh7th/cmp-vsnip',
+            'hrsh7th/vim-vsnip',
         },
-        opts = function()
-            local cmp = require('cmp')
-            return {
-                view = { entries = {name = 'custom', selection_order = 'near_cursor'} },
-                formatting = { format= require('lspkind').cmp_format({ mode = 'symbol_text' }), },
-                mapping = require('nvim-cmp').mapping.preset.insert({
-                        ['<C-j>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
-                        ['<C-k>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
-                        ['<C-p>'] = cmp.mapping.scroll_docs(-4),
-                        ['<C-n>'] = cmp.mapping.scroll_docs(4),
-                        ['<CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, }),
-                }),
-                sources = cmp.config.sources({ 
-                    { name = 'nvim_lsp' }, 
-                    { name = 'path' }, 
-                    { name = 'buffer' }
-                }),
-                cmdline(':', {
-                    view = { entries = {name = 'wildmenu', separator = '|'} },
+        config = function()
+                local cmp = require'cmp'
+                cmp.setup({
+                    snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, },
+                    formatting = {
+                        format = require('lspkind').cmp_format({ mode = "text_symbol" })
+                    },
+                    window = { },
+                    mapping = cmp.mapping.preset.insert({
+                        ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+                        ['<C-f>'] = cmp.mapping.scroll_docs(4),
+                        ['<C-Space>'] = cmp.mapping.complete(),
+                        ['<C-e>'] = cmp.mapping.abort(),
+                        ['<CR>'] = cmp.mapping.confirm({ select = true }),
+                    }),
+                    sources = cmp.config.sources({
+                        { name = 'nvim_lsp' },
+                        { name = 'vsnip' },
+                        { name = 'buffer' },
+                    })
+                })
+
+                cmp.setup.cmdline({ '/', '?' }, {
+                    view = { entries = {
+                        name = 'wildmenu',
+                        separator = '|',
+                        selection_order = 'near_cursor',
+                    } },
+                    mapping = cmp.mapping.preset.cmdline(),
+                    sources = { { name = 'buffer' } }
+                })
+
+                cmp.setup.cmdline(':', {
+                    view = { entries = {
+                        name = 'wildmenu',
+                        separator = '|',
+                        selection_order = 'near_cursor',
+                    } },
                     mapping = cmp.mapping.preset.cmdline(),
                     sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } })
                 })
-            }
+
+                local capabilities = require('cmp_nvim_lsp').default_capabilities()
+                require('lspconfig')['rust_analyzer'].setup { capabilities = capabilities }
         end
     },
 }
index 38a27e5c7712bb63eda27d9c4f25d94721978e25..e38299a9f4273f7a1e49015293c4d715548707c9 100644 (file)
@@ -1,13 +1,16 @@
 return {
     {
         'neovim/nvim-lspconfig',
+        event = { 'BufReadPre', 'BufNewFile' },
         dependencies = {
-            "mason.nvim",
-            "nvim-cmp",
-            "williamboman/mason-lspconfig.nvim",
+            'nvim-cmp',
+            'nvim-treesitter',
+            'Maan2003/lsp_lines.nvim',
+            { 'williamboman/mason.nvim', build = ':MasonUpdate' },
+            'williamboman/mason-lspconfig',
         },
-        opts = {
-            diagnostics = {
+        config = function()
+            vim.lsp.diagnostics = {
                 virtual_text = false,
                 virtual_lines = true,
                 signs = false,
@@ -15,55 +18,34 @@ return {
                 update_in_insert = false,
                 severity_sort = true,
             }
-        },
-        setup = {}
-    },
 
-    {
-        'nvim-treesitter/nvim-treesitter',
-        opts = {
-            ensure_installed = { 
-                "c",
-                "bash",
-                "comment",
-                "html", 
-                "json",
-                "markdown",
-                "rust", 
-                "regex",
-                "ruby"
-            },
-            sync_install = true,
-            auto_install = true,
-            highlight = { enable = true, additional_vim_regex_highlighting = true, },
-            indent = { enable = false },
-        }
-    },
+            local lspconfig = require('lspconfig')
+            require('mason').setup()
 
-    {
-        "williamboman/mason.nvim",
-        cmd = "Mason",
-        opts = {
-            ensure_installed = {
-                "stylua",
-                "shfmt",
-            },
-        },
+            require('mason-lspconfig').setup({
+                automatic_installation = true,
+                ensure_installed = {}
+            })
+
+            require('mason-lspconfig').setup_handlers({
+                function (server_name)
+                    lspconfig[server_name].setup({})
+                end
+            })
+        end
     },
 
     {
         "jose-elias-alvarez/null-ls.nvim",
         event = { "BufReadPre", "BufNewFile" },
-        dependencies = { "mason.nvim" },
-        opts = function()
-        local nls = require("null-ls")
-        return {
-            root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
-            sources = {
-            nls.builtins.formatting.stylua,
-            nls.builtins.formatting.shfmt,
-            },
-        }
-        end
+        dependencies = { 
+            "mason.nvim",
+            "nvim-lua/plenary.nvim",
+            {
+                "jay-babu/mason-null-ls.nvim",
+                opts = { automatic_setup = true }
+            }
+        },
     },
+
 }
diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua
new file mode 100644 (file)
index 0000000..0c7ff6f
--- /dev/null
@@ -0,0 +1,17 @@
+return {
+    {
+        'nvim-treesitter/nvim-treesitter',
+        build = function()
+            require('nvim-treesitter.install').update( { with_sync = true } )
+        end,
+        event = { 'BufReadPost', 'BufNewFile' },
+        config = function()
+            require('nvim-treesitter.configs').setup {
+                sync_install = true,
+                auto_install = true,
+                highlight = { enable = true },
+                indent = { enable = true },
+            }
+        end
+    },
+}
index c47ff86ad74424b78b0d97c535167051a0dd2e40..f860d1f0cc92aa206c3de768c9ddceadc6c20b08 100644 (file)
@@ -32,7 +32,6 @@ vim.o.cdhome = true
 
 vim.o.wrapscan = true
 vim.o.wildmenu = true
--- vim.o.wildignore = { '*.docx','*.jpg','*.png','*.pdf','*.pyc','*.exe','*.flv','*.img','*.xlsx' }
 
 vim.o.tabstop = 4
 vim.o.shiftwidth = 4
@@ -58,8 +57,6 @@ vim.o.autoread = true
 vim.o.foldenable = true
 vim.o.foldlevelstart = 5
 vim.o.foldmethod = 'indent'
--- vim.o.foldmarker = { '-v-','-^-' }
--- vim.o.backspace = { 'indent','eol','start' }
 
 vim.o.ttimeout = true
 vim.o.ttimeoutlen = 1
@@ -70,10 +67,6 @@ vim.o.splitbelow = true
 
 vim.o.showtabline = 0
 vim.o.termguicolors = true
--- vim.o.completeopt = { 'menu', 'menuone', 'noselect' }
-
-vim.o.pumblend = 30
-vim.o.pumwidth = 50
 
 vim.o.jumpoptions = 'stack'
 vim.o.so = 10