stylua formatting

This commit is contained in:
Noah Masur 2021-11-24 09:04:07 -05:00
parent f40dc276e2
commit 9e3244d8ea
2 changed files with 284 additions and 290 deletions

View File

@ -2,6 +2,7 @@
brew "shellcheck" # Lint for bash brew "shellcheck" # Lint for bash
brew "shfmt" # Formatter for bash brew "shfmt" # Formatter for bash
brew "stylua" # Formatter for lua
brew "python" # Latest version of Python brew "python" # Latest version of Python
brew "ipython" # Better interactive Python shell brew "ipython" # Better interactive Python shell
brew "poetry" # Project-based Python dependencies brew "poetry" # Project-based Python dependencies

View File

@ -1,92 +1,93 @@
-- Bootstrap the Packer plugin manager -- Bootstrap the Packer plugin manager
local fn = vim.fn local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then if fn.empty(fn.glob(install_path)) > 0 then
packer_bootstrap = fn.system( packer_bootstrap = fn.system({
{ "git",
'git', 'clone', '--depth', '1', "clone",
'https://github.com/wbthomason/packer.nvim', install_path "--depth",
} "1",
) "https://github.com/wbthomason/packer.nvim",
install_path,
})
end end
-- Packer plugin installations -- Packer plugin installations
require('packer').startup(function(use) require("packer").startup(function(use)
-- Maintain plugin manager -- Maintain plugin manager
use 'wbthomason/packer.nvim' use("wbthomason/packer.nvim")
-- Startup speed hacks -- Startup speed hacks
use { use({
'lewis6991/impatient.nvim', "lewis6991/impatient.nvim",
config = function() config = function()
require('impatient') require("impatient")
end end,
} })
-- Important tweaks -- Important tweaks
use 'tpope/vim-surround' --- Manipulate parentheses use("tpope/vim-surround") --- Manipulate parentheses
use 'tpope/vim-commentary' --- Use gc or gcc to add comments use("tpope/vim-commentary") --- Use gc or gcc to add comments
-- Convenience tweaks -- Convenience tweaks
use 'tpope/vim-eunuch' --- File manipulation in Vim use("tpope/vim-eunuch") --- File manipulation in Vim
use 'tpope/vim-vinegar' --- Fixes netrw file explorer use("tpope/vim-vinegar") --- Fixes netrw file explorer
use 'tpope/vim-fugitive' --- Git commands and syntax use("tpope/vim-fugitive") --- Git commands and syntax
use 'tpope/vim-repeat' --- Actually repeat using . use("tpope/vim-repeat") --- Actually repeat using .
use 'christoomey/vim-tmux-navigator' --- Hotkeys for tmux panes use("christoomey/vim-tmux-navigator") --- Hotkeys for tmux panes
-- Colorscheme -- Colorscheme
use { use({
'morhetz/gruvbox', "morhetz/gruvbox",
config = function() config = function()
vim.cmd[[colorscheme gruvbox]] vim.cmd([[colorscheme gruvbox]])
end end,
} })
-- Git next to line numbers -- Git next to line numbers
use { use({
'lewis6991/gitsigns.nvim', "lewis6991/gitsigns.nvim",
branch = 'main', branch = "main",
requires = {'nvim-lua/plenary.nvim'}, requires = { "nvim-lua/plenary.nvim" },
config = function() config = function()
require('gitsigns').setup() require("gitsigns").setup()
end end,
} })
-- Status bar -- Status bar
use { use({
'hoob3rt/lualine.nvim', "hoob3rt/lualine.nvim",
requires = { 'kyazdani42/nvim-web-devicons', opt = true }, requires = { "kyazdani42/nvim-web-devicons", opt = true },
config = function() config = function()
require('lualine').setup({ require("lualine").setup({
options = { options = {
theme = 'gruvbox', theme = "gruvbox",
icons_enabled = true icons_enabled = true,
} },
}) })
end end,
} })
-- Improve speed and filetype detection -- Improve speed and filetype detection
use { use({
'nathom/filetype.nvim', "nathom/filetype.nvim",
config = function() config = function()
-- Filetype for .env files -- Filetype for .env files
local envfiletype = function() local envfiletype = function()
vim.bo.filetype = 'text' vim.bo.filetype = "text"
vim.bo.syntax = 'sh' vim.bo.syntax = "sh"
end end
-- Force filetype patterns that Vim doesn't know about -- Force filetype patterns that Vim doesn't know about
require('filetype').setup({ require("filetype").setup({
overrides = { overrides = {
extensions = { extensions = {
Brewfile = 'brewfile', Brewfile = "brewfile",
muttrc = 'muttrc', muttrc = "muttrc",
hcl = 'terraform', hcl = "terraform",
}, },
literal = { literal = {
Caskfile = 'brewfile', Caskfile = "brewfile",
[".gitignore"] = 'gitignore', [".gitignore"] = "gitignore",
}, },
complex = { complex = {
[".*git/config"] = "gitconfig", [".*git/config"] = "gitconfig",
@ -103,226 +104,202 @@ require('packer').startup(function(use)
[".env.prod"] = envfiletype, [".env.prod"] = envfiletype,
[".env.example"] = envfiletype, [".env.example"] = envfiletype,
}, },
} },
}) })
end end,
} })
-- Alignment tool -- Alignment tool
use 'godlygeek/tabular' use("godlygeek/tabular")
-- Markdown renderer / wiki notes -- Markdown renderer / wiki notes
use 'vimwiki/vimwiki' use("vimwiki/vimwiki")
-- Markdown pretty view -- Markdown pretty view
use 'ellisonleao/glow.nvim' use("ellisonleao/glow.nvim")
-- Navigation -- Navigation
use { use({
'ggandor/lightspeed.nvim', "ggandor/lightspeed.nvim",
branch = 'smart-autojump' branch = "smart-autojump",
} })
-- Snippet engine -- Snippet engine
use 'L3MON4D3/LuaSnip' use("L3MON4D3/LuaSnip")
-- ======================================================================= -- =======================================================================
-- Language Server -- Language Server
-- ======================================================================= -- =======================================================================
-- Language server engine -- Language server engine
use { use({
'neovim/nvim-lspconfig', "neovim/nvim-lspconfig",
requires = { 'hrsh7th/cmp-nvim-lsp' }, requires = { "hrsh7th/cmp-nvim-lsp" },
config = function() config = function()
local capabilities = require('cmp_nvim_lsp').update_capabilities( local capabilities = require("cmp_nvim_lsp").update_capabilities(
vim.lsp.protocol.make_client_capabilities() vim.lsp.protocol.make_client_capabilities()
) )
require('lspconfig').rust_analyzer.setup{ capabilities = capabilities } require("lspconfig").rust_analyzer.setup({ capabilities = capabilities })
require('lspconfig').tflint.setup{ capabilities = capabilities } require("lspconfig").tflint.setup({ capabilities = capabilities })
require('lspconfig').terraformls.setup{ capabilities = capabilities } require("lspconfig").terraformls.setup({ capabilities = capabilities })
require('lspconfig').pyright.setup{ require("lspconfig").pyright.setup({
cmd = { "poetry", "run", "pyright-langserver", "--stdio" }, cmd = { "poetry", "run", "pyright-langserver", "--stdio" },
capabilities = capabilities, capabilities = capabilities,
} })
-- if require('lspconfig/util').has_bins('diagnostic-languageserver') then end,
-- require('lspconfig').diagnosticls.setup{ })
-- cmd = { "diagnostic-languageserver", "--stdio" },
-- filetypes = { "sh" },
-- on_attach = on_attach,
-- init_options = {
-- filetypes = { sh = "shellcheck" },
-- linters = {
-- shellcheck = {
-- sourceName = "shellcheck",
-- command = "shellcheck",
-- debounce = 100,
-- args = { "--format=gcc", "-" },
-- offsetLine = 0,
-- offsetColumn = 0,
-- formatLines = 1,
-- formatPattern = {
-- "^[^:]+:(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$",
-- { line = 1, column = 2, message = 4, security = 3 }
-- },
-- securities = { error = "error", warning = "warning", }
-- },
-- }
-- }
-- }
-- end
end
}
-- Pretty highlights -- Pretty highlights
use 'folke/lsp-colors.nvim' use("folke/lsp-colors.nvim")
-- Linting -- Linting
use { use({
'jose-elias-alvarez/null-ls.nvim', "jose-elias-alvarez/null-ls.nvim",
requires = { requires = {
'nvim-lua/plenary.nvim', "nvim-lua/plenary.nvim",
'neovim/nvim-lspconfig' "neovim/nvim-lspconfig",
}, },
config = function() config = function()
require("null-ls").config({ require("null-ls").config({
sources = { sources = {
require("null-ls").builtins.formatting.stylua, require("null-ls").builtins.formatting.stylua,
require("null-ls").builtins.formatting.black, require("null-ls").builtins.formatting.black,
require("null-ls").builtins.formatting.fish_indent, require("null-ls").builtins.formatting.fish_indent,
require("null-ls").builtins.formatting.reorder_python_imports, require("null-ls").builtins.formatting.reorder_python_imports,
require("null-ls").builtins.formatting.nixfmt, require("null-ls").builtins.formatting.nixfmt,
require("null-ls").builtins.formatting.rustfmt, require("null-ls").builtins.formatting.rustfmt,
require("null-ls").builtins.formatting.shfmt.with( { require("null-ls").builtins.formatting.shfmt.with({
extra_args = {"-i", "4", "-ci"} extra_args = { "-i", "4", "-ci" },
}), }),
require("null-ls").builtins.formatting.terraform_fmt, require("null-ls").builtins.formatting.terraform_fmt,
require("null-ls").builtins.diagnostics.shellcheck, require("null-ls").builtins.diagnostics.shellcheck,
-- require("null-ls").builtins.diagnostics.luacheck, -- require("null-ls").builtins.diagnostics.luacheck,
-- require("null-ls").builtins.diagnostics.markdownlint, -- require("null-ls").builtins.diagnostics.markdownlint,
-- require("null-ls").builtins.diagnostics.pylint, -- require("null-ls").builtins.diagnostics.pylint,
} },
}) })
require("lspconfig")["null-ls"].setup({}) require("lspconfig")["null-ls"].setup({})
end end,
} })
-- ======================================================================= -- =======================================================================
-- Completion System -- Completion System
-- ======================================================================= -- =======================================================================
-- Completion sources -- Completion sources
use 'hrsh7th/cmp-nvim-lsp' --- Language server completion plugin use("hrsh7th/cmp-nvim-lsp") --- Language server completion plugin
use 'hrsh7th/cmp-buffer' --- Generic text completion use("hrsh7th/cmp-buffer") --- Generic text completion
use 'hrsh7th/cmp-path' --- Local file completion use("hrsh7th/cmp-path") --- Local file completion
use 'hrsh7th/cmp-cmdline' --- Command line completion use("hrsh7th/cmp-cmdline") --- Command line completion
use 'hrsh7th/cmp-nvim-lua' --- Nvim lua api completion use("hrsh7th/cmp-nvim-lua") --- Nvim lua api completion
use 'saadparwaiz1/cmp_luasnip' --- Luasnip completion use("saadparwaiz1/cmp_luasnip") --- Luasnip completion
use 'lukas-reineke/cmp-rg' --- Ripgrep completion use("lukas-reineke/cmp-rg") --- Ripgrep completion
-- Completion engine -- Completion engine
use { use({
'hrsh7th/nvim-cmp', "hrsh7th/nvim-cmp",
requires = { 'L3MON4D3/LuaSnip', }, requires = { "L3MON4D3/LuaSnip" },
config = function() config = function()
local cmp = require('cmp') local cmp = require("cmp")
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end, end,
}, },
mapping = { mapping = {
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
['<Esc>'] = function(fallback) ["<Esc>"] = function(fallback)
cmp.mapping({ cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}) })
vim.cmd('stopinsert') --- Abort and leave insert mode vim.cmd("stopinsert") --- Abort and leave insert mode
end, end,
-- ['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }), -- ['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
-- ['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }), -- ['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }),
['<CR>'] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert, behavior = cmp.ConfirmBehavior.Insert,
select = true, select = true,
}), }),
['<C-r>'] = cmp.mapping.confirm({ ["<C-r>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
}), }),
['<C-l>'] = cmp.mapping(function(fallback) ["<C-l>"] = cmp.mapping(function(fallback)
if require('luasnip').expand_or_jumpable() then if require("luasnip").expand_or_jumpable() then
require('luasnip').expand_or_jump() require("luasnip").expand_or_jump()
end end
end, {"i", "s"}) end, { "i", "s" }),
}, },
sources = { sources = {
{ name = 'nvim_lua' }, { name = "nvim_lua" },
{ name = 'nvim_lsp' }, { name = "nvim_lsp" },
{ name = 'path' }, { name = "path" },
{ name = 'luasnip' }, { name = "luasnip" },
{ name = 'buffer', keyword_length = 3, max_item_count = 10 }, { name = "buffer", keyword_length = 3, max_item_count = 10 },
{ {
name = 'rg', keyword_length = 6, max_item_count = 10, name = "rg",
opts = { additional_arguments = "--ignore-case" } keyword_length = 6,
max_item_count = 10,
opts = { additional_arguments = "--ignore-case" },
}, },
}, },
experimental = { experimental = {
native_menu = false, --- Use cmp menu instead of Vim menu native_menu = false, --- Use cmp menu instead of Vim menu
ghost_text = true, --- Show preview auto-completion ghost_text = true, --- Show preview auto-completion
}, },
}) })
-- Use buffer source for `/` -- Use buffer source for `/`
cmp.setup.cmdline('/', { cmp.setup.cmdline("/", {
sources = { sources = {
{ name = 'buffer', keyword_length = 5 } { name = "buffer", keyword_length = 5 },
} },
}) })
-- Use cmdline & path source for ':' -- Use cmdline & path source for ':'
cmp.setup.cmdline(':', { cmp.setup.cmdline(":", {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' } { name = "path" },
}, { }, {
{ name = 'cmdline' } { name = "cmdline" },
}) }),
}) })
end end,
} })
-- ======================================================================= -- =======================================================================
-- Syntax -- Syntax
-- ======================================================================= -- =======================================================================
-- Syntax engine -- Syntax engine
use { use({
'nvim-treesitter/nvim-treesitter', "nvim-treesitter/nvim-treesitter",
run = ':TSUpdate', run = ":TSUpdate",
config = function() config = function()
require('nvim-treesitter.configs').setup { require("nvim-treesitter.configs").setup({
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
} })
end end,
} })
-- Additional syntax sources -- Additional syntax sources
use 'bfontaine/Brewfile.vim' --- Brewfile syntax use("bfontaine/Brewfile.vim") --- Brewfile syntax
use 'chr4/nginx.vim' --- Nginx syntax use("chr4/nginx.vim") --- Nginx syntax
use 'towolf/vim-helm' --- Helm syntax use("towolf/vim-helm") --- Helm syntax
use 'rodjek/vim-puppet' --- Puppet syntax use("rodjek/vim-puppet") --- Puppet syntax
use 'blankname/vim-fish' --- Better fish syntax use("blankname/vim-fish") --- Better fish syntax
-- ======================================================================= -- =======================================================================
-- Fuzzy Launcher -- Fuzzy Launcher
-- ======================================================================= -- =======================================================================
use { use({
'nvim-telescope/telescope.nvim', "nvim-telescope/telescope.nvim",
requires = { 'nvim-lua/plenary.nvim' }, requires = { "nvim-lua/plenary.nvim" },
config = function() config = function()
-- Telescope: quit instantly with escape -- Telescope: quit instantly with escape
local actions = require("telescope.actions") local actions = require("telescope.actions")
@ -346,74 +323,74 @@ require('packer').startup(function(use)
zoxide = {}, zoxide = {},
neoclip = {}, neoclip = {},
project = { project = {
base_dirs = { '~/dev/work', }, base_dirs = { "~/dev/work" },
}, },
}, },
}) })
end end,
} })
-- Faster sorting -- Faster sorting
use 'nvim-telescope/telescope-fzy-native.nvim' use("nvim-telescope/telescope-fzy-native.nvim")
-- Jump around tmux sessions -- Jump around tmux sessions
use 'camgraff/telescope-tmux.nvim' use("camgraff/telescope-tmux.nvim")
-- Jump directories -- Jump directories
use { use({
'jvgrootveld/telescope-zoxide', "jvgrootveld/telescope-zoxide",
requires = {'nvim-lua/popup.nvim'}, requires = { "nvim-lua/popup.nvim" },
} })
-- Jump projects -- Jump projects
use { use({
'nvim-telescope/telescope-project.nvim', "nvim-telescope/telescope-project.nvim",
requires = {'nvim-telescope/telescope.nvim'}, requires = { "nvim-telescope/telescope.nvim" },
config = function() config = function()
require('telescope').load_extension('project') require("telescope").load_extension("project")
end end,
} })
-- Clipboard history -- Clipboard history
use { use({
"AckslD/nvim-neoclip.lua", "AckslD/nvim-neoclip.lua",
branch = 'main', branch = "main",
requires = { requires = {
{'tami5/sqlite.lua', module = 'sqlite'}, { "tami5/sqlite.lua", module = "sqlite" },
{'nvim-telescope/telescope.nvim'}, { "nvim-telescope/telescope.nvim" },
}, },
config = function() config = function()
require('neoclip').setup({ require("neoclip").setup({
enable_persistant_history = true, enable_persistant_history = true,
default_register = {'+', '"'}, default_register = { "+", '"' },
keys = { keys = {
i = { paste = '<c-v>' }, i = { paste = "<c-v>" },
}, },
}) })
require('telescope').load_extension('neoclip') require("telescope").load_extension("neoclip")
end end,
} })
-- Project bookmarks -- Project bookmarks
use { use({
'ThePrimeagen/harpoon', "ThePrimeagen/harpoon",
requires = { requires = {
'nvim-lua/plenary.nvim', "nvim-lua/plenary.nvim",
'nvim-telescope/telescope.nvim' "nvim-telescope/telescope.nvim",
} },
} })
-- TLDR Lookup -- TLDR Lookup
use { use({
'mrjones2014/tldr.nvim', "mrjones2014/tldr.nvim",
requires = {'nvim-telescope/telescope.nvim'} requires = { "nvim-telescope/telescope.nvim" },
} })
-- ======================================================================= -- =======================================================================
-- Install on initial bootstrap -- Install on initial bootstrap
if packer_bootstrap then if packer_bootstrap then
require('packer').sync() require("packer").sync()
end end
end) end)
@ -421,75 +398,90 @@ end)
-- Settings -- Settings
-- =========================================================================== -- ===========================================================================
vim.o.termguicolors = true --- Set to truecolor vim.o.termguicolors = true --- Set to truecolor
vim.o.hidden = true --- Don't unload buffers when leaving them vim.o.hidden = true --- Don't unload buffers when leaving them
vim.wo.number = true --- Show line numbers vim.wo.number = true --- Show line numbers
vim.wo.relativenumber = true --- Relative numbers instead of absolute vim.wo.relativenumber = true --- Relative numbers instead of absolute
vim.o.list = true --- Reveal whitespace with dashes vim.o.list = true --- Reveal whitespace with dashes
vim.o.expandtab = true --- Tabs into spaces vim.o.expandtab = true --- Tabs into spaces
vim.o.shiftwidth = 4 --- Amount to shift with > key vim.o.shiftwidth = 4 --- Amount to shift with > key
vim.o.softtabstop = 4 --- Amount to shift with <TAB> key vim.o.softtabstop = 4 --- Amount to shift with <TAB> key
vim.o.ignorecase = true --- Ignore case when searching vim.o.ignorecase = true --- Ignore case when searching
vim.o.smartcase = true --- Check case when using capitals in search vim.o.smartcase = true --- Check case when using capitals in search
vim.o.infercase = true --- Don't match cases when completing suggestions vim.o.infercase = true --- Don't match cases when completing suggestions
vim.o.incsearch = true --- Search while typing vim.o.incsearch = true --- Search while typing
vim.o.visualbell = true --- No sounds vim.o.visualbell = true --- No sounds
vim.o.scrolljump = 1 --- Number of lines to scroll vim.o.scrolljump = 1 --- Number of lines to scroll
vim.o.scrolloff = 3 --- Margin of lines to see while scrolling vim.o.scrolloff = 3 --- Margin of lines to see while scrolling
vim.o.splitright = true --- Vertical splits on the right side vim.o.splitright = true --- Vertical splits on the right side
vim.o.splitbelow = true --- Horizontal splits on the bottom side vim.o.splitbelow = true --- Horizontal splits on the bottom side
vim.o.pastetoggle = "<F3>" --- Use F3 to enter raw paste mode vim.o.pastetoggle = "<F3>" --- Use F3 to enter raw paste mode
vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking
vim.o.updatetime = 300 --- Faster diagnostics vim.o.updatetime = 300 --- Faster diagnostics
vim.o.mouse = "nv" --- Mouse interaction / scrolling vim.o.mouse = "nv" --- Mouse interaction / scrolling
-- Neovim features -- Neovim features
vim.o.inccommand = "split" --- Live preview search and replace vim.o.inccommand = "split" --- Live preview search and replace
vim.o.completeopt = "menu,menuone,noselect" --- Required for nvim-cmp completion vim.o.completeopt = "menu,menuone,noselect" --- Required for nvim-cmp completion
-- Required until 0.6.0: do not source the default filetype.vim -- Required until 0.6.0: do not source the default filetype.vim
vim.g.did_load_filetypes = 1 vim.g.did_load_filetypes = 1
-- Remember last position when reopening file -- Remember last position when reopening file
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
]], false) ]],
false
)
-- Better backup, swap and undo storage -- Better backup, swap and undo storage
vim.o.backup = true --- Easier to recover and more secure vim.o.backup = true --- Easier to recover and more secure
vim.bo.swapfile = false --- Instead of swaps, create backups vim.bo.swapfile = false --- Instead of swaps, create backups
vim.bo.undofile = true --- Keeps undos after quit vim.bo.undofile = true --- Keeps undos after quit
-- Create backup directories if they don't exist -- Create backup directories if they don't exist
-- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433 -- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433
vim.o.backupdir = vim.fn.stdpath('cache') .. '/backup' vim.o.backupdir = vim.fn.stdpath("cache") .. "/backup"
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
if !isdirectory(&backupdir) if !isdirectory(&backupdir)
call mkdir(&backupdir, "p") call mkdir(&backupdir, "p")
endif endif
]], false) ]],
false
)
-- Formatting -- Formatting
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
au BufWritePost * silent! lua vim.lsp.buf.formatting() au BufWritePost * silent! lua vim.lsp.buf.formatting()
]], false) ]],
false
)
-- LaTeX options -- LaTeX options
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
au FileType tex inoremap ;bf \textbf{}<Esc>i au FileType tex inoremap ;bf \textbf{}<Esc>i
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
]], false) ]],
false
)
-- Highlight when yanking -- Highlight when yanking
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
]], false) ]],
false
)
-- Netrw -- Netrw
vim.g.netrw_liststyle = 3 -- Change style to 'tree' view vim.g.netrw_liststyle = 3 -- Change style to 'tree' view
vim.g.netrw_banner = 0 -- Remove useless banner vim.g.netrw_banner = 0 -- Remove useless banner
vim.g.netrw_winsize = 15 -- Explore window takes % of page vim.g.netrw_winsize = 15 -- Explore window takes % of page
vim.g.netrw_browse_split = 4 -- Open in previous window vim.g.netrw_browse_split = 4 -- Open in previous window
vim.g.netrw_altv = 1 -- Always split left vim.g.netrw_altv = 1 -- Always split left
-- VimWiki -- VimWiki
vim.g.vimwiki_list = { vim.g.vimwiki_list = {
@ -497,18 +489,19 @@ vim.g.vimwiki_list = {
["path"] = "$NOTES_PATH", ["path"] = "$NOTES_PATH",
["syntax"] = "markdown", ["syntax"] = "markdown",
["index"] = "home", ["index"] = "home",
["ext"] = ".md" ["ext"] = ".md",
} },
} }
vim.g.vimwiki_key_mappings = { vim.g.vimwiki_key_mappings = {
["all_maps"] = 1, ["all_maps"] = 1,
["mouse"] = 1, ["mouse"] = 1,
} }
vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open
vim.g.vimwiki_create_link = 0 -- Don't automatically create new links vim.g.vimwiki_create_link = 0 -- Don't automatically create new links
vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression
vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
au FileType markdown inoremap ;tt <Esc>:AddTag<CR> au FileType markdown inoremap ;tt <Esc>:AddTag<CR>
function! PInsert(item) function! PInsert(item)
@ -517,7 +510,9 @@ vim.api.nvim_exec([[
endfunction endfunction
command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')})
]], false) ]],
false
)
-- =========================================================================== -- ===========================================================================
-- Custom Functions -- Custom Functions
@ -526,58 +521,58 @@ vim.api.nvim_exec([[
grep_notes = function() grep_notes = function()
local opts = { local opts = {
prompt_title = "Search Notes", prompt_title = "Search Notes",
cwd = '$NOTES_PATH', cwd = "$NOTES_PATH",
} }
require('telescope.builtin').live_grep(opts) require("telescope.builtin").live_grep(opts)
end end
find_notes = function() find_notes = function()
local opts = { local opts = {
prompt_title = "Find Notes", prompt_title = "Find Notes",
cwd = '$NOTES_PATH', cwd = "$NOTES_PATH",
} }
require('telescope.builtin').find_files(opts) require("telescope.builtin").find_files(opts)
end end
find_downloads = function() find_downloads = function()
local opts = { local opts = {
prompt_title = "Find Downloads", prompt_title = "Find Downloads",
cwd = '~/Downloads', cwd = "~/Downloads",
} }
require('telescope.builtin').file_browser(opts) require("telescope.builtin").file_browser(opts)
end end
choose_project = function() choose_project = function()
local opts = require("telescope.themes").get_ivy { local opts = require("telescope.themes").get_ivy({
layout_config = { layout_config = {
bottom_pane = { bottom_pane = {
height = 10, height = 10,
}, },
}, },
} })
require('telescope').extensions.project.project(opts) require("telescope").extensions.project.project(opts)
end end
clipboard_history = function() clipboard_history = function()
local opts = require("telescope.themes").get_cursor { local opts = require("telescope.themes").get_cursor({
layout_config = { layout_config = {
cursor = { cursor = {
width = 150, width = 150,
}, },
}, },
} })
require('telescope').extensions.neoclip.neoclip(opts) require("telescope").extensions.neoclip.neoclip(opts)
end end
command_history = function() command_history = function()
local opts = require("telescope.themes").get_ivy { local opts = require("telescope.themes").get_ivy({
layout_config = { layout_config = {
bottom_pane = { bottom_pane = {
height = 15, height = 15,
} },
} },
} })
require('telescope.builtin').command_history(opts) require("telescope.builtin").command_history(opts)
end end
-- =========================================================================== -- ===========================================================================
@ -592,7 +587,7 @@ local key = function(mode, key_sequence, action, params)
end end
-- Remap space as leader key -- Remap space as leader key
key("", "<Space>", "<Nop>", {silent=true}) key("", "<Space>", "<Nop>", { silent = true })
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
@ -601,7 +596,7 @@ key("v", "<", "<gv")
key("v", ">", ">gv") key("v", ">", ">gv")
-- Clear search register -- Clear search register
key("n", "<CR>", ":noh<CR><CR>", {silent=true}) key("n", "<CR>", ":noh<CR><CR>", { silent = true })
-- Shuffle lines around -- Shuffle lines around
key("n", "<A-j>", ":m .+1<CR>==") key("n", "<A-j>", ":m .+1<CR>==")
@ -647,24 +642,22 @@ key("n", "<Leader>2", "<Cmd>lua require('harpoon.ui').nav_file(2)<CR><Esc>")
key("n", "<Leader>3", "<Cmd>lua require('harpoon.ui').nav_file(3)<CR><Esc>") key("n", "<Leader>3", "<Cmd>lua require('harpoon.ui').nav_file(3)<CR><Esc>")
-- LSP -- LSP
key("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", {silent=true}) key("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", { silent = true })
key("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>", {silent=true}) key("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>", { silent = true })
key("n", "gh", "<Cmd>lua vim.lsp.buf.hover()<CR>", {silent=true}) key("n", "gh", "<Cmd>lua vim.lsp.buf.hover()<CR>", { silent = true })
key("n", "]e", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>", {silent=true}) key("n", "]e", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>", { silent = true })
key("n", "[e", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", {silent=true}) key("n", "[e", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", { silent = true })
key("n", "<Leader>e", "<Cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", {silent=true}) key("n", "<Leader>e", "<Cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", { silent = true })
-- File commands -- File commands
key("n", "<Leader>q", ":quit<CR>") key("n", "<Leader>q", ":quit<CR>")
key("n", "<Leader>Q", ":quitall<CR>") key("n", "<Leader>Q", ":quitall<CR>")
key("n", "<Leader>fs", ":write<CR>") key("n", "<Leader>fs", ":write<CR>")
key("n", "<Leader>fd", ":lcd %:p:h<CR>", {silent=true}) key("n", "<Leader>fd", ":lcd %:p:h<CR>", { silent = true })
key("n", "<Leader>fu", ":lcd ..<CR>", {silent=true}) key("n", "<Leader>fu", ":lcd ..<CR>", { silent = true })
key("n", "<Leader><Tab>", ":b#<CR>", {silent=true}) key("n", "<Leader><Tab>", ":b#<CR>", { silent = true })
key("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", {silent=true}) key("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", { silent = true })
key("n", "<Leader>tt", key("n", "<Leader>tt", [[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]])
[[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]]
)
key("n", "<Leader>jj", ":!journal<CR>:e<CR>") key("n", "<Leader>jj", ":!journal<CR>:e<CR>")
-- Window commands -- Window commands
@ -684,19 +677,19 @@ key("n", "<Leader>rp", ":luafile $MYVIMRC<CR>:PackerInstall<CR>:")
key("n", "<Leader>rc", ":luafile $MYVIMRC<CR>:PackerCompile<CR>") key("n", "<Leader>rc", ":luafile $MYVIMRC<CR>:PackerCompile<CR>")
-- Keep cursor in place -- Keep cursor in place
key("n", 'n', "nzz") key("n", "n", "nzz")
key("n", 'N', "Nzz") key("n", "N", "Nzz")
key("n", 'J', "mzJ`z") --- Mark and jump back to it key("n", "J", "mzJ`z") --- Mark and jump back to it
-- Add undo breakpoints -- Add undo breakpoints
key("i", ',', ",<C-g>u") key("i", ",", ",<C-g>u")
key("i", '.', ".<C-g>u") key("i", ".", ".<C-g>u")
key("i", '!', "!<C-g>u") key("i", "!", "!<C-g>u")
key("i", '?', "?<C-g>u") key("i", "?", "?<C-g>u")
-- Other -- Other
key("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode key("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
key("n", "<A-CR>", ":noh<CR>", {silent=true}) --- Clear search in VimWiki key("n", "<A-CR>", ":noh<CR>", { silent = true }) --- Clear search in VimWiki
key("n", "Y", "y$") --- Copy to end of line key("n", "Y", "y$") --- Copy to end of line
key("v", "<C-r>", "y<Esc>:%s/<C-r>+//gc<left><left><left>") --- Substitute selected key("v", "<C-r>", "y<Esc>:%s/<C-r>+//gc<left><left><left>") --- Substitute selected
key("v", "D", "y'>gp") --- Duplicate selected key("v", "D", "y'>gp") --- Duplicate selected