more vim stuff!

This commit is contained in:
mokou 2022-03-14 17:48:55 +01:00
parent 53e92c72b7
commit cfad39f336
5 changed files with 75 additions and 36 deletions

View file

@ -1,3 +1,4 @@
LICENSE LICENSE
cool_cli_tools.md cool_cli_tools.md
packer_compiled.lua packer_compiled.lua
plugin/

View file

@ -3,10 +3,7 @@
require("options") require("options")
require("utils") require("utils")
require("plugins") require("plugins")
require("keybinds")
-- Load our color scheme -- Load our color scheme
vim.cmd("colorscheme base16-eighties") vim.cmd("colorscheme base16-eighties")
-- Initialize all of the boring plugins
require("rust-tools").setup({})
require("fidget").setup({})

View file

@ -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 = {
["<space>"] = {"<cmd>Telescope find_files<CR>", "Find file"},
b = {
name = "+buffers",
b = {"<cmd>Telescope buffers<CR>", "List buffers"},
["<tab>"] = {"<cmd>b#<CR>", "Goto other buffer"},
},
w = {
name = "+window",
v = {"<cmd>vsplit<CR>", "Split vertically"},
s = {"<cmd>split<CR>", "Split horizontally"},
q = {"<cmd>x<CR>", "Close window"}, -- No unsaved windows!!
h = {"<cmd>wincmd h<CR>", "Left"},
j = {"<cmd>wincmd j<CR>", "Down"},
k = {"<cmd>wincmd k<CR>", "Up"},
l = {"<cmd>wincmd l<CR>", "Right"},
H = {"<C-w>H", "Move Left"},
J = {"<C-w>J", "Move Down"},
K = {"<C-w>K", "Move Up"},
L = {"<C-w>L", "Move Right"},
},
l = {
name = "+lsp",
e = {"<cmd>lua vim.diagnostic.open_float()<CR>", "Show diagnostic at point"},
h = {"<cmd>lua vim.diagnostic.goto_prev()<CR>", "Goto prev diagnostic"},
l = {"<cmd>lua vim.diagnostic.goto_next()<CR>", "Goto next diagnostic"},
q = {"<cmd>Telescope diagnostics<CR>", "Show all diagnostics"},
a = {"<cmd>lua vim.lsp.add_workspace_folder()<CR>", "Add folder to workspace"},
r = {"<cmd>lua vim.lsp.remove_workspace_folder()<CR>", "Remove folder from workspace"},
R = {"<cmd>Telescope lsp_references<CR>", "List references"},
s = {"<cmd>Telescope lsp_document_symbols<CR>", "List document symbols"},
S = {"<cmd>Telescope lsp_workspace_symbols<CR>", "List workspace symbols"},
d = {"<cmd>Telescope lsp_definitions<CR>", "Goto definition"},
},
}
wk.register_keymap("leader", leader_keymap)

View file

@ -17,11 +17,17 @@ return require("packer").startup(function(use)
-- Dogfood packer -- Dogfood packer
use({"wbthomason/packer.nvim", opt = true}) use({"wbthomason/packer.nvim", opt = true})
-- Dependencies
use "nvim-lua/plenary.nvim"
-- LSP stuff -- LSP stuff
use({"neovim/nvim-lspconfig", config = function() require("plugins.lsp") end}) use({"neovim/nvim-lspconfig", config = function() require("plugins.lsp") end})
use "simrat39/rust-tools.nvim" use({"simrat39/rust-tools.nvim", config = function()
use "stevearc/aerial.nvim" require("rust-tools").setup({})
use "j-hui/fidget.nvim" end})
use({"j-hui/fidget.nvim", config = function()
require("fidget").setup({})
end})
-- Completion -- Completion
use "hrsh7th/cmp-nvim-lsp" use "hrsh7th/cmp-nvim-lsp"
@ -33,5 +39,24 @@ return require("packer").startup(function(use)
-- Fancy UI stuff -- Fancy UI stuff
use "RRethy/nvim-base16" use "RRethy/nvim-base16"
use "stevearc/dressing.nvim" 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) end)

View file

@ -1,35 +1,7 @@
-- LSP-related configuration
local Utils = require("utils")
local opts = {noremap = true, silent = true}
-- Set some useful keybinds
Utils.nmap("<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>")
Utils.nmap("[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>")
Utils.nmap("]d", "<cmd>lua vim.diagnostic.goto_next()<CR>")
Utils.nmap("<space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>")
-- Set the following keybinds only after LSP attachment -- Set the following keybinds only after LSP attachment
local on_attach = function(client, bufnr) local on_attach = function(_, bufnr)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') 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', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
require("aerial").on_attach(client, bufnr)
end end
-- Initialize servers that don't need any extra config -- Initialize servers that don't need any extra config