diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 52c8f1a..6cbb7e6 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -14,33 +14,25 @@ end M.bufferline = function() local m = plugins.bufferline - map("n", m.nextBuffer, ":BufferLineCycleNext ") - map("n", m.prevBuffer, ":BufferLineCyclePrev ") + -- map("n", m.nextBuffer, ":BufferLineCycleNext ") end M.gitsigns = function() - local m = plugins.gitsigns - - map("n", m.blameLine, ":Gitsigns blame_line ") - map("n", m.diffThis, ":Gitsigns diffthis ") + -- map("n", m.blameLine, ":Gitsigns blame_line ") + -- map("n", m.diffThis, ":Gitsigns diffthis ") end M.nvimtree = function() - local m = plugins.nvimtree - - map("n", m.toggle, ":NvimTreeToggle ") - map("n", m.focus, ":NvimTreeFocus ") + -- map("n", m.toggle, ":NvimTreeToggle ") + -- map("n", m.focus, ":NvimTreeFocus ") end M.telescope = function() - local m = plugins.telescope - - map("n", m.buffers, ":Telescope buffers ") - map("n", m.diagnostics, ":Telescope diagnostic ") - map("n", m.liveGrep, ":Telescope live_grep ") - map("n", m.files, ":Telescope find_files ") - map("n", m.gitCommits, ":Telescope git_commits ") - map("n", m.gitStatus, ":Telescope git_status ") + -- map("n", m.buffers, ":Telescope buffers ") + -- map("n", m.liveGrep, ":Telescope live_grep ") + -- map("n", m.files, ":Telescope find_files ") + -- map("n", m.gitCommits, ":Telescope git_commits ") + -- map("n", m.gitStatus, ":Telescope git_status ") end return M diff --git a/lua/plugins/config/blankline.lua b/lua/plugins/config/blankline.lua index ecf25af..7ef2447 100644 --- a/lua/plugins/config/blankline.lua +++ b/lua/plugins/config/blankline.lua @@ -1,7 +1,7 @@ require("indent_blankline").setup { indentLine_enabled = 1, char = "▏", - filetype_exclude = {"help", "terminal", "dashboard", "nvimtree"}, + filetype_exclude = {"help", "terminal", "alpha"}, buftype_exclude = {"terminal"}, show_trailing_blankline_indent = false, show_first_indent_level = false diff --git a/lua/plugins/config/cmp.lua b/lua/plugins/config/cmp.lua new file mode 100644 index 0000000..993731c --- /dev/null +++ b/lua/plugins/config/cmp.lua @@ -0,0 +1,46 @@ +local cmp = require("cmp") + +cmp.setup { + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" } + } +} diff --git a/lua/plugins/config/luasnip.lua b/lua/plugins/config/luasnip.lua new file mode 100644 index 0000000..a10f62b --- /dev/null +++ b/lua/plugins/config/luasnip.lua @@ -0,0 +1,8 @@ +local luasnip = require("luasnip") + +luasnip.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI" +} + +require("luasnip/loaders/from_vscode").load() diff --git a/lua/plugins/config/nvimtree.lua b/lua/plugins/config/nvimtree.lua index b907809..170f5f8 100644 --- a/lua/plugins/config/nvimtree.lua +++ b/lua/plugins/config/nvimtree.lua @@ -10,6 +10,11 @@ require("nvim-tree").setup { disable_netrw = true, ignore_ft_on_setup = { "dashboard" }, hijack_cursor = true, + update_cwd = true, + update_focused_file = { + enable = true, + update_cwd = true + }, git = { ignore = false }, diff --git a/lua/plugins/config/whichkey.lua b/lua/plugins/config/whichkey.lua new file mode 100644 index 0000000..11ce93b --- /dev/null +++ b/lua/plugins/config/whichkey.lua @@ -0,0 +1,35 @@ +local wk = require("which-key") + +wk.setup { + ignore_missing = true +} + +wk.register({ + [""] = { + f = { + name = "Files", + f = { "Telescope find_files", "Find File" }, + g = { "Telescope live_grep", "Live Grep" } + }, + b = { + name = "Buffers", + b = { "Telescope buffers", "Find Buffers" }, + x = { "BufDel", "Close Buffer" } + }, + t = { + name = "NvimTree", + t = { "NvimTreeToggle", "NvimTree Toggle" }, + f = { "NvimTreeFocus", "NvimTree Focus" } + } + }, + + g = { + name = "Git", + c = { "Telescope git_commits", "Git Commits" }, + s = { "Telescope git_status", "Git Status" }, + b = { "Gitsigns blame_line", "Blame Line" }, + d = { "Gitsigns diffthis", "Diff This" } + }, + + [""] = { "BufferLineCycleNext" } +}) diff --git a/lua/plugins/setup.lua b/lua/plugins/setup.lua index aa6175f..c8cc458 100644 --- a/lua/plugins/setup.lua +++ b/lua/plugins/setup.lua @@ -82,7 +82,6 @@ require("packer").startup(function(use) use { "lukas-reineke/indent-blankline.nvim", - event = "BufRead", config = function() require("plugins.config.blankline") end @@ -141,6 +140,114 @@ require("packer").startup(function(use) end } + -- LSP + use "neovim/nvim-lspconfig" + + use { + "ray-x/lsp_signature.nvim", + after = "nvim-lspconfig", + config = function() + require("lsp_signature").setup() + end + } + + use { + "rafamadriz/friendly-snippets", + module = "cmp_nvim_lsp", + event = "InsertCharPre" + } + + use { + "hrsh7th/nvim-cmp", + after = "friendly-snippets", + config = function() + require("plugins.config.cmp") + end + } + + use { + "L3MON4D3/LuaSnip", + wants = "friendly-snippets", + after = "nvim-cmp", + config = function() + require("plugins.config.luasnip") + end + } + + use { + "saadparwaiz1/cmp_luasnip", + after = "LuaSnip" + } + + use { + "hrsh7th/cmp-nvim-lua", + after = "cmp_luasnip" + } + + use { + "hrsh7th/cmp-nvim-lsp", + after = "cmp-nvim-lua" + } + + use { + "hrsh7th/cmp-buffer", + after = "cmp-nvim-lsp" + } + + use { + "hrsh7th/cmp-path", + after = "cmp-buffer" + } + + use { + "williamboman/nvim-lsp-installer", + requires = "neovim/nvim-lspconfig", + config = function() + local lspInstaller = require("nvim-lsp-installer") + + lspInstaller.on_server_ready(function(server) + local opts = {} + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] + end) + end + } + + use { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup() + end + } + + use { + "simrat39/symbols-outline.nvim", + cmd = "SymbolsOutline" + } + + use { + "folke/trouble.nvim", + requires = "kyazdani42/nvim-web-devicons", + config = function() + require("trouble").setup() + end + } + + use { + "goolord/alpha-nvim", + requires = "kyazdani42/nvim-web-devicons", + config = function() + require("alpha").setup(require("alpha.themes.dashboard").config) + end + } + + use { + "folke/which-key.nvim", + config = function() + require("plugins.config.whichkey") + end + } + if packer_bootstrap then require("packer").sync() end diff --git a/lua/plugins/whichkeymap.lua b/lua/plugins/whichkeymap.lua new file mode 100644 index 0000000..e69de29