From: Huck Boles Date: Sun, 16 Apr 2023 16:59:58 +0000 (-0500) Subject: working mason, lsp, cmp and treesitter X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=98f1cfc0eae51cad69bb0f6fccb15b47a807dc21;p=nvim.git working mason, lsp, cmp and treesitter --- diff --git a/lua/function.lua b/lua/function.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/plugins.lua b/lua/plugins.lua index 38ac366..309b3ae 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -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 diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 67d105c..42bc60e 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -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({ - [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), - [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = 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({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = 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 }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 38a27e5..e38299a 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -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 index 0000000..0c7ff6f --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -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 + }, +} diff --git a/lua/settings.lua b/lua/settings.lua index c47ff86..f860d1f 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -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