diff --git a/lazy-lock.json b/lazy-lock.json index fc2c542..61554e0 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,11 +1,19 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "2463d687fe704b76eb0aa3bb34e95f69a5bb0362" }, "bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" }, "gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" }, "indent-blankline.nvim": { "branch": "master", "commit": "5da5546947f3125dfd6aa85ab21074dc83f776d5" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lspkind.nvim": { "branch": "master", "commit": "7f26cf5e27e2bd910ce0ea00c514da2bf97423b8" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, "nvim-autopairs": { "branch": "master", "commit": "9fd41181693dd4106b3e414a822bb6569924de81" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "nvim-tree.lua": { "branch": "master", "commit": "50f30bcd8c62ac4a83d133d738f268279f2c2ce2" }, "nvim-treesitter": { "branch": "master", "commit": "7d0b4756aba3b220d38ec0443c6cc10944060dd7" }, "nvim-web-devicons": { "branch": "master", "commit": "43aa2ddf476012a2155f5f969ee55ab17174da7a" }, diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua new file mode 100644 index 0000000..976da68 --- /dev/null +++ b/lua/config/gitsigns.lua @@ -0,0 +1,8 @@ +--- Ensure plugin is avaiable +local ok, gitsigns = pcall(require, 'gitsigns') +if not ok then + return +end + +--- Load plugin +gitsigns.setup() diff --git a/lua/config/indent-blankline.lua b/lua/config/indent-blankline.lua new file mode 100644 index 0000000..322688b --- /dev/null +++ b/lua/config/indent-blankline.lua @@ -0,0 +1,8 @@ +--- Ensure plugin is avaiable +local ok, ibl = pcall(require, "ibl") +if not ok then + return +end + +--- Load plugin +ibl.setup() diff --git a/lua/config/init.lua b/lua/config/init.lua index 49691be..f858a1a 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -10,3 +10,4 @@ require("config/onedark") require("config/rainbow-delimiters") require("config/telescope") require("config/which-key") +require("config/nvim-cmp") diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua new file mode 100644 index 0000000..ee936f1 --- /dev/null +++ b/lua/config/lualine.lua @@ -0,0 +1,29 @@ +--- Ensure plugin is avaiable +local ok, lualine, lazy_status = pcall(function() + return require("lualine"), require("lazy.status") +end) +if not ok then + return +end + +--- Plugin options +opts = { + options = { + theme = "onedark", + }, + sections = { + lualine_x = { + { + lazy_status.updates, + cond = lazy_status.has_updates, + color = { fg = "#ff9e64" }, + }, + { "encoding" }, + { "fileformat" }, + { "filetype" }, + }, + }, +} + +--- Load plugin +lualine.setup(opts) diff --git a/lua/config/nvim-autopairs.lua b/lua/config/nvim-autopairs.lua new file mode 100644 index 0000000..5ac8091 --- /dev/null +++ b/lua/config/nvim-autopairs.lua @@ -0,0 +1,8 @@ +--- Ensure plugin is avaiable +local ok, nvimautopairs = pcall(require, "nvim-autopairs") +if not ok then + return +end + +--- Load plugin +nvimautopairs.setup() diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua new file mode 100644 index 0000000..eea50d7 --- /dev/null +++ b/lua/config/nvim-cmp.lua @@ -0,0 +1,43 @@ +--- Ensure plugins are installed +local ok, cmp, luasnip, lspkind = pcall(function() + return require("cmp"), + require("luasnip"), + require("lspkind") +end) + +if not ok then + return +end + +--- loads vscode style snippets from installed plugins (e.g. friendly-snippets) +require("luasnip.loaders.from_vscode").lazy_load() + +opts = { + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + },v +} diff --git a/lua/config/nvim-tree.lua b/lua/config/nvim-tree.lua new file mode 100644 index 0000000..9fa8d8e --- /dev/null +++ b/lua/config/nvim-tree.lua @@ -0,0 +1,47 @@ +--- Ensure plugin is avaiable +local ok, nvimtree = pcall(require, "nvim-tree") +if not ok then + return +end + +--- Unload netrw +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +--- Plugin options +local opts = { + sort = { + -- sorter = "case_sensitive", + }, + view = { + width = 30, + }, + renderer = { + group_empty = true, + indent_markers = { + enable = true, + }, + icons = { + glyphs = { + folder = { + arrow_closed = "", -- arrow when folder is closed + arrow_open = "", -- arrow when folder is open + }, + }, + }, + }, + filters = { + dotfiles = false, + }, +} + +--- Load plugin +nvimtree.setup(opts) + +--- Override keymap +local km = vim.keymap.set +km('n', '', ':NvimTreeFocus') +km('n', 'ee', ':NvimTreeToggle') +km('n', 'ef', ':NvimTreeFindFileToggle') +km('n', 'ec', ':NvimTreeCollapse') +km('n', 'er', ':NvimTreeRefresh') diff --git a/lua/config/nvim-treesitter.lua b/lua/config/nvim-treesitter.lua new file mode 100644 index 0000000..693c336 --- /dev/null +++ b/lua/config/nvim-treesitter.lua @@ -0,0 +1,28 @@ +--- Ensure plugin is avaiable +local ok, treesitter = pcall(require, "nvim-treesitter.configs") +if not ok then + return +end + +--- Plugin options +opts = { + highlight = { + enable = true, + }, + autotag = { + enable = true, + }, + auto_install = true, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "ss", + node_incremental = false, + scope_incremental = false, + node_decremental = false, + }, + }, +} + +--- Load plugin +treesitter.setup(opts) diff --git a/lua/config/onedark.lua b/lua/config/onedark.lua new file mode 100644 index 0000000..4d975c4 --- /dev/null +++ b/lua/config/onedark.lua @@ -0,0 +1,6 @@ +local ok, onedark = pcall(require, "onedark") +if not ok then + return +end + +onedark.load() diff --git a/lua/config/rainbow-delimiters.lua b/lua/config/rainbow-delimiters.lua new file mode 100644 index 0000000..9d2b281 --- /dev/null +++ b/lua/config/rainbow-delimiters.lua @@ -0,0 +1,28 @@ +local ok, rainbow_delimiters = pcall(require, "rainbow-delimiters") +if not ok then + return +end + +vim.g.rainbow_delimiters = { + strategy = { + [''] = rainbow_delimiters.strategy['global'], + vim = rainbow_delimiters.strategy['local'], + }, + query = { + [''] = 'rainbow-delimiters', + lua = 'rainbow-blocks', + }, + priority = { + [''] = 110, + lua = 210, + }, + highlight = { + 'RainbowDelimiterYellow', + 'RainbowDelimiterBlue', + 'RainbowDelimiterOrange', + 'RainbowDelimiterGreen', + 'RainbowDelimiterViolet', + 'RainbowDelimiterCyan', + 'RainbowDelimiterRed', + }, +} diff --git a/lua/config/telescope.lua b/lua/config/telescope.lua new file mode 100644 index 0000000..afcff0e --- /dev/null +++ b/lua/config/telescope.lua @@ -0,0 +1,12 @@ +--- Ensute telescope is installed +local ok, telescope = pcall(require, "telescope.builtin") +if not ok then + return +end + +--- Override keymaps +local km = vim.keymap.set +km("n", "ff", telescope.find_files, {desc = "find files"}) +km("n", "fg", telescope.live_grep, {desc = "live grep"}) +km("n", "fb", telescope.buffers, {desc = "buffers"}) +km("n", "fh", telescope.help_tags, {desc = "help tags"}) diff --git a/lua/config/which-key.lua b/lua/config/which-key.lua new file mode 100644 index 0000000..a8c155b --- /dev/null +++ b/lua/config/which-key.lua @@ -0,0 +1,26 @@ +--- Ensure plugin is avaiable +local ok, wichkey = pcall(require, "which-key") +if not ok then + return +end + +--- Global options +vim.o.timeout = true +vim.o.timeoutlen = 300 + +--- Add description to leader group +wichkey.register({ + n = { + name = "NoHighLight", + }, + e = { + name = "NvimTree", + }, + f = { + name = "Telescope" + }, +}, { prefix = "" }) + +--- Override keymap +local km = vim.keymap.set +km('n', '', ':WhichKey', { desc = "Which-key" }) diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..da3ed29 --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -0,0 +1,13 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + "hrsh7th/cmp-nvim-lsp", -- source from cmdline + "L3MON4D3/LuaSnip", -- snippet engine + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + }, +}