2023-01-14 20:17:04 -06:00
|
|
|
-- randomuser's
|
|
|
|
-- _ _ _ _
|
|
|
|
-- (_)_ __ (_) |_ | |_ _ __ _
|
|
|
|
-- | | '_ \| | __| | | | | |/ _` |
|
|
|
|
-- | | | | | | |_ _| | |_| | (_| |
|
|
|
|
-- |_|_| |_|_|\__(_)_|\__,_|\__,_|
|
|
|
|
|
|
|
|
-- helper functions {{{
|
2023-01-31 11:28:10 -06:00
|
|
|
local keymapper = vim.keymap
|
|
|
|
local globals = vim.g
|
|
|
|
local opt = vim.o
|
|
|
|
local cmd = vim.cmd
|
2023-01-14 20:17:04 -06:00
|
|
|
function nnoremap(l, r)
|
2023-01-31 11:28:10 -06:00
|
|
|
keymapper.set('n', l, r) -- noremap is implied
|
2023-01-14 20:17:04 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
function inoremap(l, r)
|
2023-01-31 11:28:10 -06:00
|
|
|
keymapper.set('i', l, r)
|
2023-01-14 20:17:04 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
function tnoremap(l, r)
|
2023-01-31 11:28:10 -06:00
|
|
|
keymapper.set('t', l, r)
|
2023-01-14 20:17:04 -06:00
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- custom mappings {{{
|
2023-01-31 11:28:10 -06:00
|
|
|
globals.mapleader = ' '
|
2023-01-14 20:17:04 -06:00
|
|
|
nnoremap(';', ':')
|
|
|
|
nnoremap(':', ';')
|
|
|
|
nnoremap('<leader><leader>', ':')
|
|
|
|
|
|
|
|
-- source init.vim
|
2023-09-23 03:42:22 -05:00
|
|
|
-- requires rebuilding the configuration first
|
2023-01-14 20:17:04 -06:00
|
|
|
nnoremap('<leader>rr', function()
|
2023-01-31 11:28:10 -06:00
|
|
|
cmd.source('~/.config/nvim/init.lua')
|
2023-01-14 20:17:04 -06:00
|
|
|
end)
|
|
|
|
-- edit init.vim
|
|
|
|
nnoremap('<leader>re', function()
|
2023-09-23 03:42:22 -05:00
|
|
|
cmd.edit('~/dot_testing/config/nvim/init.lua')
|
2023-01-14 20:17:04 -06:00
|
|
|
end)
|
|
|
|
-- openup netrw
|
|
|
|
nnoremap('<leader>fs', function()
|
2023-01-31 11:28:10 -06:00
|
|
|
cmd.Lexplore()
|
2023-01-14 20:17:04 -06:00
|
|
|
end)
|
|
|
|
|
|
|
|
inoremap('qp', '<c-g>u<Esc>[s1z=`]a<c-g>u')
|
|
|
|
inoremap("<C-a>", "<Esc>mZ0i<Tab><Esc>`ZlA")
|
2023-03-24 10:24:33 -05:00
|
|
|
inoremap('jk', '<Esc>')
|
|
|
|
inoremap('zz', '<Esc>:w!<CR>a')
|
2023-01-14 20:17:04 -06:00
|
|
|
|
|
|
|
tnoremap('<Esc>', '<C-\\><C-n>')
|
|
|
|
-- }}}
|
|
|
|
|
2023-04-10 08:58:48 -05:00
|
|
|
-- vim options {{{
|
|
|
|
opt.compatible = false
|
|
|
|
opt.number = true
|
|
|
|
opt.foldmethod = 'marker'
|
|
|
|
opt.encoding = 'utf8'
|
|
|
|
opt.list = true
|
|
|
|
opt.lcs = 'tab:->,trail:_,eol:^'
|
|
|
|
opt.clipboard = 'unnamedplus'
|
|
|
|
opt.spell = true
|
|
|
|
opt.spelllang = "en_us"
|
|
|
|
opt.title = true
|
|
|
|
opt.ts = 2
|
|
|
|
opt.sw = 2
|
|
|
|
opt.hlsearch = true
|
|
|
|
opt.incsearch = true
|
|
|
|
opt.ignorecase = true
|
|
|
|
opt.smartcase = true
|
|
|
|
opt.inccommand = 'nosplit'
|
|
|
|
opt.hidden = true
|
2023-04-11 17:06:15 -05:00
|
|
|
opt.linebreak = true
|
2023-04-10 08:58:48 -05:00
|
|
|
opt.path = '.,/usr/include,**'
|
|
|
|
vim.cmd.colorscheme('earth')
|
|
|
|
opt.statusline="%f %r%m%q%h%=%y 0x%02B %04l:%03c:%03p"
|
|
|
|
vim.api.nvim_exec("let &titlestring='%{expand(\"%:p\")}'", true)
|
|
|
|
|
|
|
|
globals.vimtex_view_method = 'zathura'
|
|
|
|
-- }}}
|
|
|
|
|
2023-01-14 20:17:04 -06:00
|
|
|
-- autocommands {{{
|
2023-04-02 12:47:07 -05:00
|
|
|
function setTabbing(lang, width)
|
|
|
|
vim.api.nvim_create_autocmd({"Filetype"}, {
|
|
|
|
pattern = {lang},
|
|
|
|
callback = function()
|
|
|
|
vim.bo.expandtab = true
|
|
|
|
vim.bo.tabstop = width
|
|
|
|
vim.bo.shiftwidth = width
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
setTabbing("python", 4)
|
2023-05-28 17:34:55 -05:00
|
|
|
setTabbing("javascript", 4)
|
|
|
|
setTabbing("css", 4)
|
|
|
|
setTabbing("html", 4)
|
2023-07-09 17:21:27 -05:00
|
|
|
setTabbing("nix", 2)
|
2023-01-14 20:17:04 -06:00
|
|
|
|
2023-04-10 08:58:48 -05:00
|
|
|
vim.api.nvim_create_autocmd({"TermOpen"}, {
|
|
|
|
pattern = {"*"},
|
|
|
|
callback = function()
|
|
|
|
vim.wo.number = false
|
|
|
|
end
|
|
|
|
})
|
2023-01-31 11:28:10 -06:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- netrw options {{{
|
|
|
|
globals.netrw_winsize = -28
|
|
|
|
globals.netrw_banner = 0
|
|
|
|
-- for tree view
|
|
|
|
globals.netrw_liststyle = 3
|
|
|
|
-- use previous window to open files
|
|
|
|
globals.netrw_browser_split = 4
|
2023-01-14 20:17:04 -06:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- packer.nvim {{{
|
|
|
|
-- taken from packer.nvim readme
|
|
|
|
local ensure_packer = function()
|
|
|
|
local fn = vim.fn
|
|
|
|
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
|
|
|
if fn.empty(fn.glob(install_path)) > 0 then
|
|
|
|
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
|
|
|
vim.cmd [[packadd packer.nvim]]
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local packer_bootstrap = ensure_packer()
|
|
|
|
|
2023-08-13 20:13:48 -05:00
|
|
|
local packer = require('packer').startup(function(use)
|
2023-01-14 20:17:04 -06:00
|
|
|
use 'wbthomason/packer.nvim'
|
2023-08-13 08:49:35 -05:00
|
|
|
use 'nvim-lua/plenary.nvim'
|
|
|
|
use 'nvim-telescope/telescope.nvim'
|
2023-09-23 03:42:22 -05:00
|
|
|
use 'octarect/telescope-menu.nvim'
|
2023-08-13 20:13:48 -05:00
|
|
|
use 'VonHeikemen/lsp-zero.nvim'
|
|
|
|
use 'neovim/nvim-lspconfig'
|
|
|
|
use 'hrsh7th/nvim-cmp'
|
|
|
|
use 'hrsh7th/cmp-nvim-lsp'
|
|
|
|
use 'L3MON4D3/LuaSnip'
|
2024-03-13 07:14:47 -05:00
|
|
|
use 'saadparwaiz1/cmp_luasnip'
|
2023-01-31 11:28:10 -06:00
|
|
|
use 'lervag/vimtex'
|
2023-08-18 07:49:16 -05:00
|
|
|
use 'https://github.com/protex/better-digraphs.nvim'
|
2023-01-14 20:17:04 -06:00
|
|
|
|
|
|
|
if packer_bootstrap then
|
|
|
|
require('packer').sync()
|
|
|
|
end
|
2023-01-31 11:28:10 -06:00
|
|
|
end);
|
2023-01-14 20:17:04 -06:00
|
|
|
-- }}}
|
2023-08-13 08:49:35 -05:00
|
|
|
|
|
|
|
nnoremap('<leader>ff', function()
|
|
|
|
require('telescope.builtin').find_files()
|
|
|
|
end)
|
|
|
|
|
2023-08-18 07:49:16 -05:00
|
|
|
inoremap('<C-k><C-k>', function()
|
|
|
|
require('better-digraphs').digraphs("insert")
|
|
|
|
end)
|
|
|
|
|
2024-03-13 07:14:47 -05:00
|
|
|
-- lsp config {{{
|
|
|
|
local lsp_zero = require('lsp-zero')
|
|
|
|
lsp_zero.on_attach(function(client, bufnr)
|
|
|
|
-- see :help lsp-zero-keybindings
|
|
|
|
-- to learn the available actions
|
|
|
|
lsp_zero.default_keymaps({buffer = bufnr})
|
|
|
|
end)
|
|
|
|
|
|
|
|
require('lspconfig').lua_ls.setup({})
|
|
|
|
require('lspconfig').texlab.setup({})
|
|
|
|
require('lspconfig').pylyzer.setup({})
|
|
|
|
-- }}}
|
|
|
|
|
2024-02-25 14:05:32 -06:00
|
|
|
-- luasnip configuration {{{
|
|
|
|
local luasnip = require("luasnip")
|
|
|
|
local ls_extras = require("luasnip.extras")
|
|
|
|
require("luasnip.loaders.from_snipmate").lazy_load()
|
|
|
|
vim.cmd[[
|
|
|
|
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
|
|
|
|
]]
|
|
|
|
|
|
|
|
luasnip.add_snippets("tex", {
|
|
|
|
luasnip.snippet("env", {
|
|
|
|
luasnip.text_node("\\begin{"), luasnip.insert_node(1), luasnip.text_node("}"),
|
|
|
|
luasnip.text_node({ "", "\t" }), luasnip.insert_node(0),
|
|
|
|
luasnip.text_node({ "", "\\end{" }), ls_extras.rep(1), luasnip.text_node("}")
|
|
|
|
})
|
|
|
|
})
|
2024-03-13 07:14:47 -05:00
|
|
|
|
|
|
|
luasnip.add_snippets("tex", {
|
|
|
|
luasnip.snippet("desc", {
|
|
|
|
luasnip.text_node("\\begin{description}"),
|
|
|
|
luasnip.text_node({ "", "\t\\item " }), luasnip.insert_node(1),
|
|
|
|
luasnip.text_node({ "", "\\end{description}" })
|
|
|
|
})
|
|
|
|
})
|
2024-02-25 14:05:32 -06:00
|
|
|
-- }}}
|
|
|
|
|
2023-08-13 08:49:35 -05:00
|
|
|
return packer
|