From cbf84f876a54af6d470674aeb4e7f6b5899719eb Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Sat, 8 Jul 2023 00:49:18 -0700 Subject: [PATCH] Move to lua folder --- conf/config.lua | 18 ----------- conf/git.lua | 8 ----- conf/keybinds.lua | 32 -------------------- conf/langs/general.lua | 45 ---------------------------- conf/langs/python.lua | 19 ------------ conf/plugins.lua | 74 --------------------------------------------- conf/search.lua | 22 -------------- conf/ui.lua | 12 -------- init.lua | 16 +++++----- lua/conf/config.lua | 18 +++++++++++ lua/conf/git.lua | 8 +++++ lua/conf/keybinds.lua | 32 ++++++++++++++++++++ lua/conf/langs/general.lua | 45 ++++++++++++++++++++++++++++ lua/conf/langs/python.lua | 19 ++++++++++++ lua/conf/plugins.lua | 75 ++++++++++++++++++++++++++++++++++++++++++++++ lua/conf/search.lua | 22 ++++++++++++++ lua/conf/ui.lua | 12 ++++++++ lua/ui.lua | 4 +++ ui.lua | 4 --- 19 files changed, 244 insertions(+), 241 deletions(-) delete mode 100644 conf/config.lua delete mode 100644 conf/git.lua delete mode 100644 conf/keybinds.lua delete mode 100644 conf/langs/general.lua delete mode 100644 conf/langs/python.lua delete mode 100644 conf/plugins.lua delete mode 100644 conf/search.lua delete mode 100644 conf/ui.lua create mode 100644 lua/conf/config.lua create mode 100644 lua/conf/git.lua create mode 100644 lua/conf/keybinds.lua create mode 100644 lua/conf/langs/general.lua create mode 100644 lua/conf/langs/python.lua create mode 100644 lua/conf/plugins.lua create mode 100644 lua/conf/search.lua create mode 100644 lua/conf/ui.lua create mode 100644 lua/ui.lua delete mode 100644 ui.lua diff --git a/conf/config.lua b/conf/config.lua deleted file mode 100644 index 1d7e4ba..0000000 --- a/conf/config.lua +++ /dev/null @@ -1,18 +0,0 @@ --- General Configurations (Any language/Tool) - --- Stripping trailing whitespace on save -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = { "*" }, - command = [[:%s/\s\+$//e]] -}) - --- Standard variables -vim.opt.expandtab = true -- tabs to spaces -vim.opt.tabstop = 2 -- spaces entered when tab key is pressed -vim.opt.shiftwidth = 2 -- spaces entered for indentation -vim.opt.number = true -- Line numbering -vim.opt.clipboard = "unnamedplus" -- Share system clipboard -vim.opt.eol = true -- End of line at bottom of file -vim.opt.shiftround = true -vim.opt.list = true -vim.opt.listchars={tab = »·, trail=·} diff --git a/conf/git.lua b/conf/git.lua deleted file mode 100644 index f32198f..0000000 --- a/conf/git.lua +++ /dev/null @@ -1,8 +0,0 @@ --- Fugitive Configuration --- --- Fugitive bindings -vim.api.nvim_set_keymap('n', 'gs', ':Git', {noremap = true}) -vim.api.nvim_set_keymap('n', 'gd', ':Git diff', {noremap = true}) -vim.api.nvim_set_keymap('n', 'gb', ':Git blame', {noremap = true}) -vim.api.nvim_set_keymap('n', 'gc', ':Git commit', {noremap = true}) -vim.api.nvim_set_keymap('n', 'gp', ':Git push', {noremap = true}) diff --git a/conf/keybinds.lua b/conf/keybinds.lua deleted file mode 100644 index f9552d7..0000000 --- a/conf/keybinds.lua +++ /dev/null @@ -1,32 +0,0 @@ --- General-Purpose keybinds -local keymap_opts = { silent = true, noremap = true } - -function NumberToggle() - if vim.o.relativenumber then - vim.opt.relativenumber = false - vim.opt.number = true - else - vim.opt.relativenumber = true - end -end - --- Space is the leader key when outside of insert mode. -vim.g.mapleader = " " - -vim.api.nvim_set_keymap('', 't', ':NERDTreeToggle', {silent = true}) - --- -r controls relative line numbering. -vim.api.nvim_set_keymap('n', 'r', 'lua NumberToggle()', keymap_opts) - --- Pressing enter in command mode clears the current search highlighting until --- the next search. -vim.api.nvim_set_keymap('n', '', ':noh', keymap_opts) - --- This one maps F5 to delete all trailing whitespace -vim.api.nvim_set_keymap( - 'n', - '', - [[:let _s=@/:%s/\s\+$//e:let @/=_s:nohl]], - keymap_opts) - - diff --git a/conf/langs/general.lua b/conf/langs/general.lua deleted file mode 100644 index 7fb57bd..0000000 --- a/conf/langs/general.lua +++ /dev/null @@ -1,45 +0,0 @@ --- General configuration -vim.g.ale_linters = { - python = {'black', 'flake8'}, - c: {'clang-format'}, - cpp: {'clang-format'} -} - -vim.g.ale_fixers = { - ['*'] = {'remove_trailing_lines', 'trim_whitespace'} -} - -let g:ale_fix_on_save = 1 - --- Treesitter config. -require'nvim-treesitter.configs'.setup { - ensure_installed = { - "c", - "lua", - "markdown", - "python", - "query", - "vim", - "vimdoc", - }, - - -- Prefer asynchronous install for ensure_installed. - sync_install = false, - auto_install = true, - - highlight = { - enable = true, - - -- Disable for excessively large files. - disable = function(lang, buf) - local max_filesize = 100 * 1024 -- 100 KB - local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) - if ok and stats and stats.size > max_filesize then - return true - end - end, - - -- Disable vim regex highlighting. May intefer with some `indent` style stuff. - additional_vim_regex_highlighting = false, - }, -} diff --git a/conf/langs/python.lua b/conf/langs/python.lua deleted file mode 100644 index 9bd08f7..0000000 --- a/conf/langs/python.lua +++ /dev/null @@ -1,19 +0,0 @@ --- Python configurations - -vim.api.nvim_create_autocmd( - { - "BufNewFile", - "BufRead", - }, - { - pattern = "*.py", - callback = function() - local buf = vim.api.nvim_get_current_buf() - vim.api.nvim_buf_set_option(buf, "expandtab") - vim.api.nvim_buf_set_option(buf, "autoindent") - vim.api.nvim_buf_set_option(buf, "tabstop", 4) - vim.api.nvim_buf_set_option(buf, "softtabstop", 4) - vim.api.nvim_buf_set_option(buf, "shiftwidth", 4) - end - } -) diff --git a/conf/plugins.lua b/conf/plugins.lua deleted file mode 100644 index 9d41515..0000000 --- a/conf/plugins.lua +++ /dev/null @@ -1,74 +0,0 @@ --- Plugin definitions. - -local vim = vim -local Plug = vim.fn['plug#'] - --- I have no idea how to auto-install vim-plug on Windows --- so you will have to install it manually. -vim.cmd [[ - if !(has('win16') || has('win32') || has('win64')) - if empty(glob('~/.config/nvim/autoload/plug.vim')) - silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall | source % - endif - endif -]] - -vim.call('plug#begin', '~/.config/nvim/plugged') - --- UI -Plug 'arcticicestudio/nord-vim' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'ryanoasis/vim-devicons' -Plug 'preservim/nerdtree' --- This plugin has been archived so if there are problems --- They may emerge here -Plug 'Xuyuanp/nerdtree-git-plugin' -Plug('nvim-treesitter/nvim-treesitter', {['do'] = vim.fn[':TSUpdate']}) - --- General Editing -Plug 'tpope/vim-surround' -Plug 'tpope/vim-commentary' - --- Search -Plug 'kien/ctrlp.vim' - --- Git -Plug 'tpope/vim-fugitive' - --- LSP -Plug 'prabirshrestha/vim-lsp' -Plug 'mattn/vim-lsp-settings' - --- Autocomplete -Plug 'prabirshrestha/asyncomplete.vim' -Plug 'prabirshrestha/asyncomplete-lsp.vim' - --- Tmux Helper -Plug 'preservim/vimux' -Plug 'christoomey/vim-tmux-navigator' - --- Linting -Plug 'w0rp/ale' - --- Planning -Plug 'jceb/vim-orgmode' - --- Commands -Plug 'skywind3000/asyncrun.vim' - --- Syntax highlighting -Plug 'sheerun/vim-polyglot' - --- Languages - -------------------------- --- Python -------------------------- - --- Pyenv Support -Plug 'lambdalisue/vim-pyenv' - -vim.call('plug#end') diff --git a/conf/search.lua b/conf/search.lua deleted file mode 100644 index da465ac..0000000 --- a/conf/search.lua +++ /dev/null @@ -1,22 +0,0 @@ --- Specific search configurations - --- ctrlp hotkeys -vim.g.ctrlp_map = '' -vim.g.ctrlp_cmd = 'CtrlP' - --- Rebind Ctrl-P to match the window opening keys of nerd tree -vim.g.ctrl_p_prompt_mappings = { - ['AcceptSelection("h")'] = {'','',''}, - ['AcceptSelection("v")'] = {'','' }, -} - --- ctrlp configuration -vim.opt.wildignore = { - "*/tmp/*", - "*.so", - "*.swp", - "*.zip", - "*\\tmp\\*", - "*.exe", - "*.out" -} diff --git a/conf/ui.lua b/conf/ui.lua deleted file mode 100644 index de68cb6..0000000 --- a/conf/ui.lua +++ /dev/null @@ -1,12 +0,0 @@ --- UI Definitions - -vim.cmd [[colorscheme nord]] - --- Helps some themes. -vim.opt.termguicolors = true - --- Always show hidden files in nerdtree -vim.g.NERDTreeShowHidden = 1 - - - diff --git a/init.lua b/init.lua index 0c8a02b..cfd6a3b 100644 --- a/init.lua +++ b/init.lua @@ -1,14 +1,16 @@ -- Initialization -require('/conf/plugins') -require('/conf/keybinds') -require('/conf/config') -require('/conf/ui') -require('/conf/search') -require('/conf/git') +local config_path = vim.fn.stdpath('config') .. '/' + +require('conf.plugins') +require('conf.keybinds') +require('conf.config') +require('conf.ui') +require('conf.search') +require('conf.git') require('ui') -local paths = vim.fn.glob(vim.fn.stdpath 'config' .. 'config/langs/*.lua', true, true, true) +local paths = vim.fn.glob('lua/conf/langs/*.lua', true, true, true) for _, file in ipairs(paths) do require(file) diff --git a/lua/conf/config.lua b/lua/conf/config.lua new file mode 100644 index 0000000..1d7e4ba --- /dev/null +++ b/lua/conf/config.lua @@ -0,0 +1,18 @@ +-- General Configurations (Any language/Tool) + +-- Stripping trailing whitespace on save +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = { "*" }, + command = [[:%s/\s\+$//e]] +}) + +-- Standard variables +vim.opt.expandtab = true -- tabs to spaces +vim.opt.tabstop = 2 -- spaces entered when tab key is pressed +vim.opt.shiftwidth = 2 -- spaces entered for indentation +vim.opt.number = true -- Line numbering +vim.opt.clipboard = "unnamedplus" -- Share system clipboard +vim.opt.eol = true -- End of line at bottom of file +vim.opt.shiftround = true +vim.opt.list = true +vim.opt.listchars={tab = »·, trail=·} diff --git a/lua/conf/git.lua b/lua/conf/git.lua new file mode 100644 index 0000000..f32198f --- /dev/null +++ b/lua/conf/git.lua @@ -0,0 +1,8 @@ +-- Fugitive Configuration +-- +-- Fugitive bindings +vim.api.nvim_set_keymap('n', 'gs', ':Git', {noremap = true}) +vim.api.nvim_set_keymap('n', 'gd', ':Git diff', {noremap = true}) +vim.api.nvim_set_keymap('n', 'gb', ':Git blame', {noremap = true}) +vim.api.nvim_set_keymap('n', 'gc', ':Git commit', {noremap = true}) +vim.api.nvim_set_keymap('n', 'gp', ':Git push', {noremap = true}) diff --git a/lua/conf/keybinds.lua b/lua/conf/keybinds.lua new file mode 100644 index 0000000..f9552d7 --- /dev/null +++ b/lua/conf/keybinds.lua @@ -0,0 +1,32 @@ +-- General-Purpose keybinds +local keymap_opts = { silent = true, noremap = true } + +function NumberToggle() + if vim.o.relativenumber then + vim.opt.relativenumber = false + vim.opt.number = true + else + vim.opt.relativenumber = true + end +end + +-- Space is the leader key when outside of insert mode. +vim.g.mapleader = " " + +vim.api.nvim_set_keymap('', 't', ':NERDTreeToggle', {silent = true}) + +-- -r controls relative line numbering. +vim.api.nvim_set_keymap('n', 'r', 'lua NumberToggle()', keymap_opts) + +-- Pressing enter in command mode clears the current search highlighting until +-- the next search. +vim.api.nvim_set_keymap('n', '', ':noh', keymap_opts) + +-- This one maps F5 to delete all trailing whitespace +vim.api.nvim_set_keymap( + 'n', + '', + [[:let _s=@/:%s/\s\+$//e:let @/=_s:nohl]], + keymap_opts) + + diff --git a/lua/conf/langs/general.lua b/lua/conf/langs/general.lua new file mode 100644 index 0000000..7fb57bd --- /dev/null +++ b/lua/conf/langs/general.lua @@ -0,0 +1,45 @@ +-- General configuration +vim.g.ale_linters = { + python = {'black', 'flake8'}, + c: {'clang-format'}, + cpp: {'clang-format'} +} + +vim.g.ale_fixers = { + ['*'] = {'remove_trailing_lines', 'trim_whitespace'} +} + +let g:ale_fix_on_save = 1 + +-- Treesitter config. +require'nvim-treesitter.configs'.setup { + ensure_installed = { + "c", + "lua", + "markdown", + "python", + "query", + "vim", + "vimdoc", + }, + + -- Prefer asynchronous install for ensure_installed. + sync_install = false, + auto_install = true, + + highlight = { + enable = true, + + -- Disable for excessively large files. + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + + -- Disable vim regex highlighting. May intefer with some `indent` style stuff. + additional_vim_regex_highlighting = false, + }, +} diff --git a/lua/conf/langs/python.lua b/lua/conf/langs/python.lua new file mode 100644 index 0000000..9bd08f7 --- /dev/null +++ b/lua/conf/langs/python.lua @@ -0,0 +1,19 @@ +-- Python configurations + +vim.api.nvim_create_autocmd( + { + "BufNewFile", + "BufRead", + }, + { + pattern = "*.py", + callback = function() + local buf = vim.api.nvim_get_current_buf() + vim.api.nvim_buf_set_option(buf, "expandtab") + vim.api.nvim_buf_set_option(buf, "autoindent") + vim.api.nvim_buf_set_option(buf, "tabstop", 4) + vim.api.nvim_buf_set_option(buf, "softtabstop", 4) + vim.api.nvim_buf_set_option(buf, "shiftwidth", 4) + end + } +) diff --git a/lua/conf/plugins.lua b/lua/conf/plugins.lua new file mode 100644 index 0000000..ca67dc9 --- /dev/null +++ b/lua/conf/plugins.lua @@ -0,0 +1,75 @@ +-- Plugin definitions. + +local vim = vim +local Plug = vim.fn['plug#'] +local config_path = vim.fn.stdpath('config') .. '/' + +-- I have no idea how to auto-install vim-plug on Windows +-- so you will have to install it manually. +vim.cmd [[ + if !(has('win16') || has('win32') || has('win64')) + if empty(glob('~/.config/nvim/autoload/plug.vim')) + silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall | source % + endif + endif +]] + +vim.call('plug#begin', config_path .. 'plugged') + +-- UI +Plug 'arcticicestudio/nord-vim' +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'ryanoasis/vim-devicons' +Plug 'preservim/nerdtree' +-- This plugin has been archived so if there are problems +-- They may emerge here +Plug 'Xuyuanp/nerdtree-git-plugin' +Plug('nvim-treesitter/nvim-treesitter', {['do'] = vim.fn[':TSUpdate']}) + +-- General Editing +Plug 'tpope/vim-surround' +Plug 'tpope/vim-commentary' + +-- Search +Plug 'kien/ctrlp.vim' + +-- Git +Plug 'tpope/vim-fugitive' + +-- LSP +Plug 'prabirshrestha/vim-lsp' +Plug 'mattn/vim-lsp-settings' + +-- Autocomplete +Plug 'prabirshrestha/asyncomplete.vim' +Plug 'prabirshrestha/asyncomplete-lsp.vim' + +-- Tmux Helper +Plug 'preservim/vimux' +Plug 'christoomey/vim-tmux-navigator' + +-- Linting +Plug 'w0rp/ale' + +-- Planning +Plug 'jceb/vim-orgmode' + +-- Commands +Plug 'skywind3000/asyncrun.vim' + +-- Syntax highlighting +Plug 'sheerun/vim-polyglot' + +-- Languages + +------------------------- +-- Python +------------------------- + +-- Pyenv Support +Plug 'lambdalisue/vim-pyenv' + +vim.call('plug#end') diff --git a/lua/conf/search.lua b/lua/conf/search.lua new file mode 100644 index 0000000..da465ac --- /dev/null +++ b/lua/conf/search.lua @@ -0,0 +1,22 @@ +-- Specific search configurations + +-- ctrlp hotkeys +vim.g.ctrlp_map = '' +vim.g.ctrlp_cmd = 'CtrlP' + +-- Rebind Ctrl-P to match the window opening keys of nerd tree +vim.g.ctrl_p_prompt_mappings = { + ['AcceptSelection("h")'] = {'','',''}, + ['AcceptSelection("v")'] = {'','' }, +} + +-- ctrlp configuration +vim.opt.wildignore = { + "*/tmp/*", + "*.so", + "*.swp", + "*.zip", + "*\\tmp\\*", + "*.exe", + "*.out" +} diff --git a/lua/conf/ui.lua b/lua/conf/ui.lua new file mode 100644 index 0000000..de68cb6 --- /dev/null +++ b/lua/conf/ui.lua @@ -0,0 +1,12 @@ +-- UI Definitions + +vim.cmd [[colorscheme nord]] + +-- Helps some themes. +vim.opt.termguicolors = true + +-- Always show hidden files in nerdtree +vim.g.NERDTreeShowHidden = 1 + + + diff --git a/lua/ui.lua b/lua/ui.lua new file mode 100644 index 0000000..060c963 --- /dev/null +++ b/lua/ui.lua @@ -0,0 +1,4 @@ +-- UI Definitions + +vim.cmd [[colorscheme nord]] + diff --git a/ui.lua b/ui.lua deleted file mode 100644 index 060c963..0000000 --- a/ui.lua +++ /dev/null @@ -1,4 +0,0 @@ --- UI Definitions - -vim.cmd [[colorscheme nord]] -