diff --git a/README.md b/README.md index cb330db..fbc5298 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ # README +## - IMPORTANT NOTE - +> If one of the installed plugins don't work (i.e. Mason) +> Start by updating neovim to the newest dev build +> It should fix the issues + ### Documentation on how my neovim install is configured - The File Structure of my configuration @@ -21,16 +26,15 @@ ```text 📁 ~/.config/nvim -├── 📁 after -├── 📁 ftplugin ├── 📁 lua -│ ├── 📁 other_modules -│ └── ⚙ init.lua -├── 📁 plugin -│ └── ⚙ init-vim-plug.vim -├── 📁 syntax -├── 📁 TMP -├── 📁 vimplug +│ └── 📁 stevenmm +│ ├── 📁 lazy +│ │ └── ⚙ plugin_name.lua +│ ├── ⚙ init.lua +│ ├── ⚙ lazy_init.lua +│ ├── ⚙ remap.lua +│ ├── ⚙ set.lua +│ └── ⚙ variables.lua ├── ⚙ README.md └── ⚙ init.vim ``` diff --git a/lazy-lock.json b/lazy-lock.json index eb31647..039a553 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -11,6 +11,7 @@ "fzf-lua": { "branch": "main", "commit": "9b84b53f3297d4912d7eb95b979e9b27e2e61281" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, "lazy.nvim": { "branch": "main", "commit": "e5e9bf48211a13d9ee6c1077c88327c49c1ab4a0" }, + "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, @@ -19,12 +20,15 @@ "mini.move": { "branch": "main", "commit": "c8b30e92dd2668dd6e56a9a23cb7d4ee38c2266d" }, "mini.pairs": { "branch": "main", "commit": "1a3e73649c0eaef2f6c48ce1e761c6f0a7c11918" }, "mini.surround": { "branch": "main", "commit": "f90069c7441a5fb04c3de42eacf93e16b64dd3eb" }, + "nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" }, "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, "nvim-lspconfig": { "branch": "master", "commit": "6b63bdf2399b9bedf93297d98419550523a9ad68" }, + "nvim-svelte-snippets": { "branch": "main", "commit": "0b8ceaebd528e52656303ddf66c584e9b67a52ba" }, "nvim-tree.lua": { "branch": "master", "commit": "6709463b2d18e77f7a946027917aa00d4aaed6f4" }, "nvim-treesitter": { "branch": "master", "commit": "5774e7d3da4f681296a87fcd85d17779ad362a4f" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "1020869742ecb191f260818234517f4a1515cfe8" }, "plenary": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, diff --git a/lua/stevenmm/lazy/cmp.lua b/lua/stevenmm/lazy/cmp.lua new file mode 100644 index 0000000..d2a9bf9 --- /dev/null +++ b/lua/stevenmm/lazy/cmp.lua @@ -0,0 +1,92 @@ +return { + "hrsh7th/nvim-cmp", + + dependencies = { + "windwp/nvim-autopairs", + + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "onsails/lspkind.nvim", + }, + + config = function () + print("cmp.lua") + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require('cmp') + local cmp_select = { behavior = cmp.SelectBehavior.Select } + local lspkind = require("lspkind") + + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) + + cmp.setup({ + enabled = function() + -- disable completion in comments + local context = require('cmp.config.context') + -- keep command mode completion enabled when cursor is in a comment + if vim.api.nvim_get_mode().mode == 'c' then + return true + else + return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") + end + end, + + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', + max_width = { + menu = 50, + abbr = 50, + }, + show_labelDetails = true + }), + }, + + -- preselect = { cmp.PreselectMode.Item }, + performance = { + max_view_entries = 10, + }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('nvim-svelte-snippets'). + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [''] = cmp.mapping.complete({ + config = { + sources = { + { name = 'luasnip' } + } + } + }), + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + --[''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + }), + + }) + end +} diff --git a/lua/stevenmm/lazy/commentstring.lua b/lua/stevenmm/lazy/commentstring.lua new file mode 100644 index 0000000..f8c524e --- /dev/null +++ b/lua/stevenmm/lazy/commentstring.lua @@ -0,0 +1,8 @@ +return { + 'JoosepAlviste/nvim-ts-context-commentstring', + config = function () + require('ts_context_commentstring').setup({ + enable_autocmd = false, + }) + end +} diff --git a/lua/stevenmm/lazy/lsp.lua b/lua/stevenmm/lazy/lsp.lua index 8bdf667..a6b2642 100644 --- a/lua/stevenmm/lazy/lsp.lua +++ b/lua/stevenmm/lazy/lsp.lua @@ -1,122 +1,44 @@ return { "neovim/nvim-lspconfig", + + -- Load each package config using the dependencies order dependencies = { + + -- mason configs: "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", + + -- cmp configs: "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "hrsh7th/nvim-cmp", + + -- LuaSnip config: "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", + + "nvim-svelte/nvim-svelte-snippets", + + -- fidget config: "j-hui/fidget.nvim", }, config = function() - local cmp = require('cmp') - local cmp_lsp = require("cmp_nvim_lsp") - local capabilities = vim.tbl_deep_extend( - "force", - {}, - vim.lsp.protocol.make_client_capabilities(), - cmp_lsp.default_capabilities()) + print("lsp.lua") require("fidget").setup({}) - require("mason").setup() - require("mason-lspconfig").setup({ - ensure_installed = { - "gopls", - "clangd", - "lua_ls", - "rust_analyzer", - -- "php" - -- "tsserver", - }, - handlers = { - function(server_name) -- default handler (optional) - - require("lspconfig")[server_name].setup { - capabilities = capabilities - } - end, - - ["lua_ls"] = function() - local lspconfig = require("lspconfig") - lspconfig.lua_ls.setup { - capabilities = capabilities, - settings = { - Lua = { - diagnostics = { - globals = { "vim", "it", "describe", "before_each", "after_each" }, - } - } - } - } - end, - - ["clangd"] = function () - local lspconfig = require("lspconfig") - lspconfig.clangd.setup({ - capabilities = capabilities, - }) - end, - ["gopls"] = function () - local lspconfig = require("lspconfig") - lspconfig.gopls.setup { - capabilities = capabilities, - } - end - } - }) - - local cmp_select = { behavior = cmp.SelectBehavior.Select } - - cmp.setup({ --- completion = { autocomplete = true }, - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), - [''] = cmp.mapping.complete({ - config = { - sources = { - { name = 'luasnip' } - } - } - }), - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - --[''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, { - { name = 'buffer' }, - }), - }) vim.diagnostic.config({ - -- virtual_text = false, + -- virtual_text = false, signs = { - text = { - [vim.diagnostic.severity.ERROR] = 'îȘ‡', - [vim.diagnostic.severity.WARN] = '', - [vim.diagnostic.severity.INFO] = '', - [vim.diagnostic.severity.HINT] = '󰌶', - } + text = { + [vim.diagnostic.severity.ERROR] = 'îȘ‡', + [vim.diagnostic.severity.WARN] = '', + [vim.diagnostic.severity.INFO] = '', + [vim.diagnostic.severity.HINT] = '󰌶', + } }, update_in_insert = true, float = { @@ -129,8 +51,8 @@ return { }, }) - -- vim.o.updatetime = 250 - -- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] + -- vim.o.updatetime = 250 + -- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] end } diff --git a/lua/stevenmm/lazy/mason.lua b/lua/stevenmm/lazy/mason.lua new file mode 100644 index 0000000..0a44517 --- /dev/null +++ b/lua/stevenmm/lazy/mason.lua @@ -0,0 +1,62 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "williamboman/mason-lspconfig.nvim", + }, + config = function () + print('mason.lua') + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + require('cmp_nvim_lsp').default_capabilities() + ) + + require('mason').setup({}) + require('mason-lspconfig').setup({ + ensure_installed = { + "gopls", + "clangd", + "lua_ls", + "rust_analyzer", + -- "php" + -- "tsserver", + }, + handlers = { + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = { "vim", "it", "describe", "before_each", "after_each" }, + } + } + } + } + end, + + ["clangd"] = function () + local lspconfig = require("lspconfig") + lspconfig.clangd.setup({ + capabilities = capabilities, + }) + end, + ["gopls"] = function () + local lspconfig = require("lspconfig") + lspconfig.gopls.setup { + capabilities = capabilities, + } + end + } + }) + end +} diff --git a/lua/stevenmm/lazy/minicomment.lua b/lua/stevenmm/lazy/minicomment.lua index 5c3ea4a..e5718c9 100644 --- a/lua/stevenmm/lazy/minicomment.lua +++ b/lua/stevenmm/lazy/minicomment.lua @@ -1,7 +1,13 @@ return { - 'echasnovski/mini.comment', - version = false, - config = function () - require('mini.comment').setup() - end + 'echasnovski/mini.comment', + version = false, + config = function() + require('mini.comment').setup({ + options = { + custom_commentstring = function() + return require('ts_context_commentstring').calculate_commentstring() or vim.bo.commentstring + end + }, + }) + end } diff --git a/lua/stevenmm/lazy/nvim-autopairs.lua b/lua/stevenmm/lazy/nvim-autopairs.lua new file mode 100644 index 0000000..4a22436 --- /dev/null +++ b/lua/stevenmm/lazy/nvim-autopairs.lua @@ -0,0 +1,5 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true +} diff --git a/lua/stevenmm/lazy_init.lua b/lua/stevenmm/lazy_init.lua index 07dd3e1..fc28238 100644 --- a/lua/stevenmm/lazy_init.lua +++ b/lua/stevenmm/lazy_init.lua @@ -14,5 +14,6 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ spec = "stevenmm.lazy", change_detection = { notify = false }, + 'JoosepAlviste/nvim-ts-context-commentstring', -- "nvim-lua/plenary.nvim" }) diff --git a/lua/stevenmm/remap.lua b/lua/stevenmm/remap.lua index 1e7f019..5bd32e1 100644 --- a/lua/stevenmm/remap.lua +++ b/lua/stevenmm/remap.lua @@ -5,6 +5,7 @@ local keyset = vim.keymap.set keyset("", "", "") keyset("n", "ma", ":Mason", { silent = true }) keyset("n", "na", ":NvimTreeToggle", { silent = true }) +keyset('n', 'la', ":Lazy", { silent = true }) keyset("n", "fb", ":Telescope file_browser path=%:p:h", { noremap = true, silent = true }) keyset("n", "ha", ":Telescope harpoon marks", { noremap = true, silent = true }) -keyset('n', 'se', ":Telescope emoji", { desc = '[S]earch [E]moji' }) +keyset('n', 'se', ":Telescope emoji", { desc = '[S]earch [E]moji' }) diff --git a/lua/stevenmm/set.lua b/lua/stevenmm/set.lua index b3c8d93..2ffe52e 100644 --- a/lua/stevenmm/set.lua +++ b/lua/stevenmm/set.lua @@ -6,23 +6,30 @@ vim.opt.relativenumber = true vim.opt.encoding = 'UTF-8' vim.opt.guifont = 'NotoSansM Nerd Font Mono' -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.softtabstop = -1 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 vim.opt.smarttab = false -vim.opt.expandtab = false +vim.opt.expandtab = true vim.opt.smartindent = false vim.opt.wrap = false +vim.opt.linebreak = false +-- vim.opt.textwidth = 80 +vim.opt.colorcolumn = "80" +-- vim.opt.formatoptions = "t" +-- vim.opt_local.columns = 80 vim.opt.swapfile = false vim.opt.backup = false if vim.fn.has('win32') or vim.fn.has('win64') then vim.opt.undodir = os.getenv("XDG_CONFIG_HOME") .. "/.vim/undodir" + vim.opt.shell = 'powershell.exe' else vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" + vim.opt.shell = 'bash' end vim.opt.undofile = true @@ -37,5 +44,3 @@ vim.opt.signcolumn = "yes" vim.opt.isfname:append("@-@") vim.opt.updatetime = 50 - -vim.opt.colorcolumn = "80"