nvim: move more config into lua

This commit is contained in:
dogeystamp 2024-03-03 20:11:43 -05:00
parent c599929e4f
commit fa861d2b81
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
7 changed files with 67 additions and 28 deletions

View File

@ -39,6 +39,8 @@ once the dotfiles are installed, see `~/.config/dot_profile.example` for more in
rather than through conventional means. This has less complexity than a plugin manager since I already manage all my dotfiles under Git.
Plugins are declared in `.gitmodules`.
- Submodules may take a lot of space (as of writing 0.5GB), so you may want to `git submodule deinit -f` some of them, manually pick the plugins you want, or even forgo all submodules.
**Desktop Preview**
![preview](https://raw.githubusercontent.com/DogeyStamp/dots/main/preview.png)

View File

@ -10,11 +10,3 @@ source $XDG_CONFIG_HOME/nvim/vimspector.vim
" auto-pairs
let g:AutoPairsFlyMode = 0
" trouble.nvim
nnoremap <leader>dxx <cmd>TroubleToggle<cr>
nnoremap <leader>dxw <cmd>TroubleToggle workspace_diagnostics<cr>
nnoremap <leader>dxd <cmd>TroubleToggle document_diagnostics<cr>
nnoremap <leader>dxq <cmd>TroubleToggle quickfix<cr>
nnoremap <leader>dxl <cmd>TroubleToggle loclist<cr>
nnoremap gR <cmd>TroubleToggle lsp_references<cr>

View File

@ -67,8 +67,8 @@ nnoremap <silent> <C-l> :vertical resize +5<cr>
" exit all (akin to ZZ, ZQ)
nnoremap <silent> ZF :qa<cr>
" copy URL under cursor to clipboard bind
:nnoremap <silent><leader>uu :let @+ = expand('<cfile>')<CR>
" see .config/nvim/lua/init.lua
lua require('init')
" The rest will not be sourced if the system is on minimal settings.
if $SYSTEM_PROFILE == "MINIMAL"
@ -96,11 +96,4 @@ highlight GitGutterDelete ctermfg=red
" fancy picker stuff
source $XDG_CONFIG_HOME/nvim/telescope.vim
source $XDG_CONFIG_HOME/nvim/color.vim
if $SYSTEM_PROFILE == "DEFAULT"
" see .config/nvim/lua/init.lua
lua require('init')
endif

View File

@ -1,5 +1,8 @@
-- stuff for coding
confutil = require("confutil")
keymap = confutil.keymap
------
@ -42,6 +45,12 @@ require('trouble').setup({
},
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
})
keymap("<leader>dxx", "<cmd>TroubleToggle<cr>")
keymap("<leader>dxw", "<cmd>TroubleToggle workspace_diagnostics<cr>")
keymap("<leader>dxd", "<cmd>TroubleToggle document_diagnostics<cr>")
keymap("<leader>dxq", "<cmd>TroubleToggle quickfix<cr>")
keymap("<leader>dxl", "<cmd>TroubleToggle loclist<cr>")
keymap("gR", "<cmd>TroubleToggle lsp_references<cr>")

View File

@ -0,0 +1,34 @@
-- configuration utility functions and variables
local M = {}
-- nnoremap, etc.
function M.keymap(key, cmd, params)
if params == nil then
params = {}
end
default_params = {
silent=true,
mode="n",
noremap=true,
}
setmetatable(params, {
__index = function (table, key)
return default_params[key]
end
})
vim.api.nvim_set_keymap(params.mode, key, cmd, { silent=params.silent, noremap=params.noremap })
end
-- see ~/.config/dot_profile.example for info
-- enables/disables features based on system profile
M.profile_table = {
DEFAULT=80,
SLIM=40,
MINIMAL=10,
}
M.dotprofile = M.profile_table[os.getenv("SYSTEM_PROFILE")] or profile_table.SLIM
return M

View File

@ -1,3 +1,10 @@
-- lua entry point
confutil = require("confutil")
keymap = confutil.keymap
dotprofile, profile_table = confutil.dotprofile, confutil.profile_table
--------------------------------
--------------------------------
-- miscellaneous plugins
@ -14,11 +21,12 @@ require("urlview").setup({
next = "<leader>uh",
},
})
-- bind to copy URL under cursor
keymap("<leader>uu", ":let @+ = expand('<cfile>')<cr>")
------
-- fancy prompts
-- plug: dressing.nvim
-- plug: dressing.nvim, telescope.nvim, plenary.nvim
------
require('dressing').setup({
input = {
@ -26,6 +34,13 @@ require('dressing').setup({
}
})
keymap("<leader>ef", "<cmd>Telescope find_files<cr>")
keymap("<leader>eg", "<cmd>Telescope live_grep<cr>")
keymap("<leader>em", "<cmd>Telescope buffers<cr>")
keymap("<leader>eh", "<cmd>Telescope help_tags<cr>")
keymap("<leader>es", "<cmd>Telescope lsp_document_symbols<cr>")
keymap("<leader>eb", "<cmd>Telescope keymaps<cr>")
--------------------------------
@ -34,4 +49,6 @@ require('dressing').setup({
--------------------------------
--------------------------------
require("coding")
if dotprofile >= profile_table.DEFAULT then
require("coding")
end

View File

@ -1,8 +0,0 @@
" depends on: telescope.nvim, plenary.nvim
nnoremap <leader>ef <cmd>Telescope find_files<cr>
nnoremap <leader>eg <cmd>Telescope live_grep<cr>
nnoremap <leader>em <cmd>Telescope buffers<cr>
nnoremap <leader>eh <cmd>Telescope help_tags<cr>
nnoremap <leader>es <cmd>Telescope lsp_document_symbols<cr>
nnoremap <leader>eb <cmd>Telescope keymaps<cr>