diff options
| author | Ian Griffin <migriffin@disroot.org> | 2022-09-30 20:06:55 +0800 |
|---|---|---|
| committer | Ian Griffin <migriffin@disroot.org> | 2022-09-30 20:06:55 +0800 |
| commit | 0e1bf5aad478a4030f31acd8bbea874b71e42f43 (patch) | |
| tree | b31312df0273548387a613ff2f4e00bc6828b379 /lua | |
initial commit
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/binds.lua | 26 | ||||
| -rw-r--r-- | lua/conftool.lua | 37 | ||||
| -rw-r--r-- | lua/defs.lua | 8 | ||||
| -rw-r--r-- | lua/filetypes.lua | 26 | ||||
| -rw-r--r-- | lua/ide.lua | 161 | ||||
| -rw-r--r-- | lua/misc.lua | 70 | ||||
| -rw-r--r-- | lua/ui.lua | 67 |
7 files changed, 395 insertions, 0 deletions
diff --git a/lua/binds.lua b/lua/binds.lua new file mode 100644 index 0000000..6f00728 --- /dev/null +++ b/lua/binds.lua @@ -0,0 +1,26 @@ +-- +-- Configuration Tools +-- +local ct = require('conftool') +local defs = require('defs') + +-- +-- Maps +-- +-- select all +ct.map('n', '<C-a>', '<esc>ggVG<LF>') +--[[ +-- spawn terminal +ct.map('n', '<C-M-t>', ':!' .. defs.external_term .. ' . &<LF><LF>') +-- spwan file manager +ct.map('n', '<C-M-f>', ':!' .. defs.external_filemgr .. ' . &<LF><LF>') +]] +-- spellchecking +ct.map('n', '<C-s>', ':set spell!<LF>') + +-- +-- Commands +-- +ct.defcmd('Xrdb', '!xrdb %') +ct.defcmd('ExTerm', '!' .. defs.external_term .. '&<LF><LF>') +ct.defcmd('ExFileMgr', '!' .. defs.external_filemgr .. '&<LF><LF>') diff --git a/lua/conftool.lua b/lua/conftool.lua new file mode 100644 index 0000000..864a925 --- /dev/null +++ b/lua/conftool.lua @@ -0,0 +1,37 @@ +local conftool = {} + +function conftool.set(...) + for _,a in ipairs{...} do + if type(a) == "string" then + vim.opt[a] = true; + elseif type(a) == "table" then + local val = false + if #a == 2 then val = a[2] + elseif #a == 1 then val = true end + vim.opt[ a[1] ] = val + end + end +end + +function conftool.augroup(name, ...) + vim.cmd('augroup ' .. name) + vim.cmd('autocmd!') + for _, autocmd in ipairs{...} do + vim.cmd('autocmd ' .. table.concat(autocmd, ' ')) + end + vim.cmd('augroup END') +end + +function conftool.map(mode, keyseq, argcmd, argopts) + local opts = {noremap = true} + if argopts then opts = vim.tbl_extend('force', defopts, opts) end + vim.api.nvim_set_keymap(mode, keyseq, argcmd, opts) +end + +function conftool.defcmd(cmd, repl, attr, redef) + if not redef then redef = '' end + if not attr then attr = '' end + vim.cmd('command' .. redef .. ' ' .. cmd .. ' ' .. attr .. ' ' .. repl) +end + +return conftool diff --git a/lua/defs.lua b/lua/defs.lua new file mode 100644 index 0000000..7d69ee6 --- /dev/null +++ b/lua/defs.lua @@ -0,0 +1,8 @@ +return { + -- Yes, I use the Mate desktop environment + template_dir = '~/templates', + external_term = 'mate-terminal', + external_filemgr = 'caja', + external_pdfviewer = 'atril', + lsp_path = vim.env.HOME .. '/.local/share/lsp_servers' +} diff --git a/lua/filetypes.lua b/lua/filetypes.lua new file mode 100644 index 0000000..464f8b5 --- /dev/null +++ b/lua/filetypes.lua @@ -0,0 +1,26 @@ +-- +-- Configuration Tools +-- +local ct = require('conftool') +local defs = require('defaults') +-- +-- Templates +-- +ct.augroup('templates', + {'BufNewFile', '*.c', '0r', defs.template_dir .. '/c_stdio.c'}, + {'BufNewFile', '*.cpp', '0r', defs.template_dir .. '/cpp_iostream.cpp'}, + {'BufNewFile', '*.html', '0r', defs.template_dir .. '/html.html'}, + {'BufNewFile', '*.html', '0r', defs.template_dir .. '/html.html'}, + {'BufNewFile', '*.py', '0r', defs.template_dir .. '/py.py'}, + {'BufNewFile', '*.sh', '0r', defs.template_dir .. '/sh.sh'} +) + +-- +-- FileType based Settings +-- +ct.augroup('filetypeSettings', + {'FileType', 'python', 'setlocal', 'tabstop=4 shiftwidth=4 expandtab'}, + {'FileType', 'html', 'setlocal', 'tabstop=2 shiftwidth=2 expandtab'}, + {'FileType', 'javascript', 'setlocal', 'tabstop=2 shiftwidth=2 expandtab'}, + {'FileType', 'vue', 'setlocal', 'tabstop=2 shiftwidth=2 expandtab'} +) diff --git a/lua/ide.lua b/lua/ide.lua new file mode 100644 index 0000000..ff5a62d --- /dev/null +++ b/lua/ide.lua @@ -0,0 +1,161 @@ +-- +-- IDE-like features +-- + +-- Load required tools +local pk_use = require 'packer'.use +local ct = require 'conftool' + + +-- +-- Tree Sitter +-- +pk_use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + config = function() + require('nvim-treesitter.configs').setup{ + ensure_installed = { + "bash", + "bibtex", + "c", + "cpp", + "css", + "go", + "html", + "javascript", + "json", + "latex", + "python", + "typescript", + "vim", + }, + sync_install = false, + highlight = { + enable = true, + } + } + end +} + +-- +-- Autocompletion +-- +pk_use { + 'ms-jpq/coq_nvim', + branch = 'coq', + config = function() + vim.cmd([[autocmd VimEnter * COQnow]]) + end +} +pk_use { + 'ms-jpq/coq.artifacts', + branch = 'artifacts' +} + +-- +-- Language Configurations +-- +pk_use 'ap/vim-css-color' +-- close tags in html languages +pk_use { + 'alvan/closetag.vim', + ft = {"html", "vue"} +} +pk_use { + 'fatih/vim-go', + ft = 'go' +} +pk_use { + 'lervag/vimtex', + ft = 'tex', + config = function() + local defs = require 'defaults' + vim.g.vimtex_view_general_viewer = defs.external_pdfviewer + vim.g.vimtex_compiler_latexmk_engines = { _ = '-xelatex'} + vim.g.vimtex_compiler_progname = 'nvim' + end +} + + +-- +-- Language Server +-- + +-- Basic commands +pk_use 'nanotee/nvim-lsp-basics' + +-- Language Server Installer +pk_use { + 'williamboman/mason.nvim', + config = function() + require('mason').setup() + end +} +pk_use { + 'williamboman/mason-lspconfig.nvim', + requires = { + 'williamboman/mason.nvim', + 'ms-jpq/coq_nvim' + }, + config = function() + local masonlsp = require 'mason-lspconfig' + masonlsp.setup { + ensure_installed = { + "sumneko_lua", + "gopls", + "vimls" + } + } + masonlsp.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup(require('coq').lsp_ensure_capabilities { + on_attach = function(client, bufnr) + local basics = require('lsp_basics') + basics.make_lsp_commands(client, bufnr) + basics.make_lsp_mappings(client, bufnr) + end + }) + end + } + end +} + +pk_use {'neovim/nvim-lspconfig'} + +-- +-- Show code diagnostics in a separate buffer window +-- +pk_use { + 'folke/trouble.nvim', + config = function() + require('trouble').setup { + icons = false, + fold_open = "v", + fold_closed = ">", + signs = { + error = "E:", + warning = "W:", + hint = "H:", + information = "I:" + }, + use_diagnostic_signs = false + } + + require('conftool').map('n', '<C-S-`>', ':TroubleToggle<CR>') + end +} + +-- +-- Debugger Adapter Protocol +-- +--[[ +pk_use { + 'mfussenegger/nvim-dap', + config = function() + local dap = require('dap') + + end +} +--]] + diff --git a/lua/misc.lua b/lua/misc.lua new file mode 100644 index 0000000..add8984 --- /dev/null +++ b/lua/misc.lua @@ -0,0 +1,70 @@ +local ct = require('conftool') +local pk_use = require('packer').use + +-- +-- Encoding +-- +ct.set({'encoding', 'utf-8'}, {'fileencoding', 'utf-8'}) + +-- +-- Search +-- +ct.set('wildmenu', 'incsearch', 'hlsearch') +vim.opt.backspace = 'indent,eol,start' + +-- +-- Folds +-- +ct.augroup('AutoSaveFolds', { + 'BufWinLeave,BufLeave,BufWritePost', + '?*', 'nested silent!', + 'mkview!' + },{ + 'BufWinEnter', '?*', 'silent!', 'loadview' + } +) + +-- +-- Spell Checking +-- +ct.set({'spelllang', {'en', 'cjk', 'id'}}) +ct.set({'spellsuggest', {'best', 5}}) + +-- +-- Focus Mode +-- +pk_use { + 'junegunn/goyo.vim', + cmd = 'Goyo' +} + +-- +-- Multi-cursor +-- +pk_use { + 'mg979/vim-visual-multi', + keys = {"<C-Up>", "<C-Down>"} +} + +-- +-- Netrw built-in file manager +-- +vim.g.netrw_liststyle = 3 -- tree style display +vim.g.netrw_banner = 0 -- no banner needed +vim.g.netrw_browse_split = 4 +vim.g.netrw_winsize = 15 -- small window size +vim.g.netrw_chgwin = 1 + +-- +-- EtC. +-- +vim.opt.compatible = false +vim.opt.autowrite = true +-- auto cd to the current file's location +vim.cmd('autocmd BufEnter * silent! lcd %:p:h') +-- highlighting for other langs in markdown docs +vim.g.markdown_fenced_languages = {'html', 'vim', 'python', 'c', 'bash=sh'} +-- auto close delimiters (eg. parentheses, brackets) +pk_use 'Raimondi/delimitMate' + + diff --git a/lua/ui.lua b/lua/ui.lua new file mode 100644 index 0000000..e391a73 --- /dev/null +++ b/lua/ui.lua @@ -0,0 +1,67 @@ +local pk_use = require 'packer'.use +local ct = require 'conftool' + +-- +-- Theme +-- +vim.cmd('syntax on') +--[[ +pk_use { + 'ellisonleao/gruvbox.nvim', + config = function() + require('conftool').set({'background', "light"}) + require('gruvbox').setup({ + italic = true, + bold = true, + contrast = "hard" + }) + vim.cmd [[colo gruvbox]] +-- end +--} +--]] +pk_use { + 'Th3Whit3Wolf/one-nvim', + config = function() + require('conftool').set({'background', "light"}) + vim.cmd [[colorscheme one-nvim]] + end +} + +-- +-- Indentation +-- +vim.cmd('filetype plugin indent on') +ct.set('autoindent', 'smartindent', 'cindent') +ct.set({'tabstop', 5}, {'shiftwidth', 5}) + +-- +-- Indent indicators +-- +vim.opt.list = true +vim.cmd([[set lcs=tab:\|\ ]]) +pk_use { + 'Yggdroot/indentLine', + setup = function() + vim.g.indentLine_char = '|' + vim.g.indentLine_setConceal = 0 + end +} + +-- +-- EtC. +-- +ct.set('ruler', 'showcmd', 'cursorline', 'number', 'termguicolors', 'title') +ct.set( + {'signcolumn', 'yes:1'}, + {'laststatus', 1}, + {'background', 'light'}, + {'conceallevel', 0}, + {'textwidth', 0}, + {'wrapmargin', 0}, + {'laststatus', 1} +) + +-- dont show line number in terminal window +vim.cmd('autocmd TermOpen * setlocal nonu') +-- turn on mouse +vim.opt.mouse = 'a' |
