diff --git a/.chezmoiignore b/.chezmoiignore index 208cea6..7385967 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -1,3 +1,4 @@ LICENSE cool_cli_tools.md packer_compiled.lua +plugin/ diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index 78422cc..357165c 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -3,10 +3,7 @@ require("options") require("utils") require("plugins") +require("keybinds") -- Load our color scheme vim.cmd("colorscheme base16-eighties") - --- Initialize all of the boring plugins -require("rust-tools").setup({}) -require("fidget").setup({}) diff --git a/dot_config/nvim/lua/keybinds.lua b/dot_config/nvim/lua/keybinds.lua new file mode 100644 index 0000000..8d58685 --- /dev/null +++ b/dot_config/nvim/lua/keybinds.lua @@ -0,0 +1,44 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " +vim.g.which_key_use_floating_win = 1 +vim.g.which_key_timeout = 300 + +local wk = require("whichkey_setup") + +local leader_keymap = { + [""] = {"Telescope find_files", "Find file"}, + b = { + name = "+buffers", + b = {"Telescope buffers", "List buffers"}, + [""] = {"b#", "Goto other buffer"}, + }, + w = { + name = "+window", + v = {"vsplit", "Split vertically"}, + s = {"split", "Split horizontally"}, + q = {"x", "Close window"}, -- No unsaved windows!! + h = {"wincmd h", "Left"}, + j = {"wincmd j", "Down"}, + k = {"wincmd k", "Up"}, + l = {"wincmd l", "Right"}, + H = {"H", "Move Left"}, + J = {"J", "Move Down"}, + K = {"K", "Move Up"}, + L = {"L", "Move Right"}, + }, + l = { + name = "+lsp", + e = {"lua vim.diagnostic.open_float()", "Show diagnostic at point"}, + h = {"lua vim.diagnostic.goto_prev()", "Goto prev diagnostic"}, + l = {"lua vim.diagnostic.goto_next()", "Goto next diagnostic"}, + q = {"Telescope diagnostics", "Show all diagnostics"}, + a = {"lua vim.lsp.add_workspace_folder()", "Add folder to workspace"}, + r = {"lua vim.lsp.remove_workspace_folder()", "Remove folder from workspace"}, + R = {"Telescope lsp_references", "List references"}, + s = {"Telescope lsp_document_symbols", "List document symbols"}, + S = {"Telescope lsp_workspace_symbols", "List workspace symbols"}, + d = {"Telescope lsp_definitions", "Goto definition"}, + }, +} + +wk.register_keymap("leader", leader_keymap) diff --git a/dot_config/nvim/lua/plugins.lua b/dot_config/nvim/lua/plugins.lua index 7e8ef0d..ae8f5e7 100644 --- a/dot_config/nvim/lua/plugins.lua +++ b/dot_config/nvim/lua/plugins.lua @@ -17,11 +17,17 @@ return require("packer").startup(function(use) -- Dogfood packer use({"wbthomason/packer.nvim", opt = true}) + -- Dependencies + use "nvim-lua/plenary.nvim" + -- LSP stuff use({"neovim/nvim-lspconfig", config = function() require("plugins.lsp") end}) - use "simrat39/rust-tools.nvim" - use "stevearc/aerial.nvim" - use "j-hui/fidget.nvim" + use({"simrat39/rust-tools.nvim", config = function() + require("rust-tools").setup({}) + end}) + use({"j-hui/fidget.nvim", config = function() + require("fidget").setup({}) + end}) -- Completion use "hrsh7th/cmp-nvim-lsp" @@ -33,5 +39,24 @@ return require("packer").startup(function(use) -- Fancy UI stuff use "RRethy/nvim-base16" use "stevearc/dressing.nvim" + use({"nvim-lualine/lualine.nvim", config = function() + require("lualine").setup({ + options = { + icons_enabled = false, + }, + sections = { + lualine_x = {"filetype"}, + }, + }) + end}) + + -- Keybinds + use({ + "AckslD/nvim-whichkey-setup.lua", + requires = {"liuchengxu/vim-which-key"} + }) + + -- File interaction + use({"nvim-telescope/telescope.nvim", config = function () end}) end) diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua index ad5370f..468b9cf 100644 --- a/dot_config/nvim/lua/plugins/lsp.lua +++ b/dot_config/nvim/lua/plugins/lsp.lua @@ -1,35 +1,7 @@ --- LSP-related configuration -local Utils = require("utils") -local opts = {noremap = true, silent = true} - --- Set some useful keybinds -Utils.nmap("e", "lua vim.diagnostic.open_float()") -Utils.nmap("[d", "lua vim.diagnostic.goto_prev()") -Utils.nmap("]d", "lua vim.diagnostic.goto_next()") -Utils.nmap("q", "lua vim.diagnostic.setloclist()") - -- Set the following keybinds only after LSP attachment -local on_attach = function(client, bufnr) +local on_attach = function(_, bufnr) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) - - require("aerial").on_attach(client, bufnr) end -- Initialize servers that don't need any extra config