add fundamental nvim and vim configs
This commit is contained in:
parent
285321fa38
commit
99c942cc3b
8 changed files with 274 additions and 0 deletions
41
dot_config/nvim/lua/options.lua
Normal file
41
dot_config/nvim/lua/options.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
-- Visual
|
||||
vim.o.conceallevel = 0
|
||||
vim.o.cmdheight = 1
|
||||
vim.o.pumheight = 10
|
||||
vim.o.showmode = false
|
||||
vim.o.title = true
|
||||
vim.o.termguicolors = true
|
||||
vim.wo.number = true
|
||||
vim.wo.signcolumn = "yes"
|
||||
|
||||
-- Behaviour
|
||||
vim.o.hlsearch = true
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
vim.o.smarttab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.expandtab = true
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.splitbelow = true
|
||||
vim.o.splitright = true
|
||||
vim.o.scrolloff = 12
|
||||
vim.o.sidescrolloff = 8
|
||||
vim.o.mouse = "a"
|
||||
|
||||
-- Vim specific
|
||||
vim.o.hidden = true
|
||||
vim.o.fileencoding = "utf-8"
|
||||
vim.o.spell = false
|
||||
vim.o.completeopt = "menuone,noinsert,noselect"
|
||||
vim.o.wildmode = "longest,full"
|
||||
vim.o.updatetime = 300
|
||||
|
||||
-- Disable inline error messages
|
||||
vim.diagnostic.config {
|
||||
virtual_text = false,
|
||||
underline = false,
|
||||
signs = true,
|
||||
}
|
||||
|
22
dot_config/nvim/lua/plugins.lua
Normal file
22
dot_config/nvim/lua/plugins.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
-- Plugin definitions and loading
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Rerun packer install when this file changes
|
||||
cmd([[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
|
||||
augroup end
|
||||
]])
|
||||
|
||||
-- Load packer
|
||||
cmd([[packadd packer.nvim]])
|
||||
|
||||
-- Get plugins
|
||||
return require("packer").startup(function(use)
|
||||
-- Dogfood packer
|
||||
use({"wbthomason/packer.nvim", opt = true})
|
||||
|
||||
-- LSP stuff
|
||||
use({"neovim/nvim-lspconfig", config = function() require("plugins.lsp") end})
|
||||
end)
|
67
dot_config/nvim/lua/plugins/lsp.lua
Normal file
67
dot_config/nvim/lua/plugins/lsp.lua
Normal file
|
@ -0,0 +1,67 @@
|
|||
-- 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
|
||||
local on_attach = function(_, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
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)
|
||||
end
|
||||
|
||||
-- Initialize servers that don't need any extra config
|
||||
local simple_servers = {"rust_analyzer"}
|
||||
for _, lsp in pairs(simple_servers) do
|
||||
require("lspconfig")[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
-- LSP: Lua (Sumneko)
|
||||
local runtime_path = vim.split(package.path, ";")
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
require("lspconfig").sumneko_lua.setup {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = {"vim"},
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
12
dot_config/nvim/lua/utils.lua
Normal file
12
dot_config/nvim/lua/utils.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
-- General utilities
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.map(mode, lhs, rhs)
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, {silent = true})
|
||||
end
|
||||
|
||||
function M.nmap(lhs, rhs) M.map("n", lhs, rhs) end
|
||||
function M.xmap(lhs, rhs) M.map("x", lhs, rhs) end
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue