nvim: add config files
This commit is contained in:
5
nvim/lua/config/autocmd.lua
Normal file
5
nvim/lua/config/autocmd.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
pattern = { "*" },
|
||||
command = "%s/\\s\\+$//e"
|
||||
})
|
||||
|
||||
7
nvim/lua/config/globals.lua
Normal file
7
nvim/lua/config/globals.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
vim.opt.updatetime = 750
|
||||
vim.opt.colorcolumn = "80"
|
||||
vim.opt.conceallevel = 2
|
||||
vim.opt.nuw = 6
|
||||
vim.opt.number = true
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.cursorlineopt = "number"
|
||||
31
nvim/lua/config/keybinds.lua
Normal file
31
nvim/lua/config/keybinds.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- Set leader key to Space
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
-- When lsp-signature (or any other vsnip snippet) is active, press TAB to jump
|
||||
-- to the next placehol
|
||||
--imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
|
||||
--smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
|
||||
|
||||
--imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
|
||||
--smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
|
||||
|
||||
-- Map semicolon to colon, so you don't have to press shift to enter commands
|
||||
vim.keymap.set('n', ';', ':')
|
||||
|
||||
-- Map shift-space to underscore
|
||||
--vim.keymap.set('i', '<S-Space>', '_')
|
||||
|
||||
vim.keymap.set('n', 'H', function() vim.cmd('wincmd h') end, { remap = true })
|
||||
vim.keymap.set('n', 'J', function() vim.cmd('wincmd j') end, { remap = true })
|
||||
vim.keymap.set('n', 'K', function() vim.cmd('wincmd k') end, { remap = true })
|
||||
vim.keymap.set('n', 'L', function() vim.cmd('wincmd l') end, { remap = true })
|
||||
|
||||
vim.keymap.set('n', '<C-h>', function() vim.cmd('vertical resize -1') end, {})
|
||||
vim.keymap.set('n', '<C-j>', function() vim.cmd('horizontal resize -1') end, {})
|
||||
vim.keymap.set('n', '<C-k>', function() vim.cmd('horizontal resize +1') end, {})
|
||||
vim.keymap.set('n', '<C-l>', function() vim.cmd('vertical resize +1') end, {})
|
||||
|
||||
--nmap <silent> <C-t> :ToggleTerm<CR>
|
||||
--imap <silent> <C-t> :ToggleTerm<CR>
|
||||
|
||||
--nmap <silent> t :ToggleTerm<CR>
|
||||
35
nvim/lua/config/lazy.lua
Normal file
35
nvim/lua/config/lazy.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||
-- loading lazy.nvim so that mappings are correct.
|
||||
-- This is also a good place to setup other settings (vim.opt)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "habamax" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true },
|
||||
})
|
||||
43
nvim/lua/config/lsp.lua
Normal file
43
nvim/lua/config/lsp.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
function show_diagnostic()
|
||||
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if vim.api.nvim_win_get_config(winid).zindex then
|
||||
return
|
||||
end
|
||||
end
|
||||
-- THIS IS FOR BUILTIN LSP
|
||||
vim.diagnostic.open_float(0, {
|
||||
scope = "cursor",
|
||||
focusable = false,
|
||||
close_events = {
|
||||
"CursorMoved",
|
||||
"CursorMovedI",
|
||||
"BufHidden",
|
||||
"InsertCharPre",
|
||||
"WinLeave",
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
||||
callback = function (args)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = args.buf,
|
||||
callback = function ()
|
||||
vim.lsp.buf.format { async = false, id = args.data.client_id }
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
pattern = '*',
|
||||
callback = show_diagnostic
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
vim.lsp.enable('clangd')
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
vim.lsp.config('clangd', {
|
||||
capabilities = capabilities
|
||||
})
|
||||
1
nvim/lua/config/misc.lua
Normal file
1
nvim/lua/config/misc.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.cmd('syntax sync minlines=20')
|
||||
Reference in New Issue
Block a user