From ed46f1c5e82709417085b1a3b7708b209c5f4bfe Mon Sep 17 00:00:00 2001 From: ottjk Date: Sat, 30 Dec 2023 19:23:04 -0500 Subject: initial commit --- nvim/lua/colorscheme.lua | 18 ++++++++++ nvim/lua/commands.lua | 10 ++++++ nvim/lua/keymaps.lua | 85 ++++++++++++++++++++++++++++++++++++++++++++ nvim/lua/luasnip-helpers.lua | 41 +++++++++++++++++++++ nvim/lua/luasnip-nodes.lua | 31 ++++++++++++++++ nvim/lua/options.lua | 26 ++++++++++++++ nvim/lua/plugins.lua | 74 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 285 insertions(+) create mode 100644 nvim/lua/colorscheme.lua create mode 100644 nvim/lua/commands.lua create mode 100644 nvim/lua/keymaps.lua create mode 100644 nvim/lua/luasnip-helpers.lua create mode 100644 nvim/lua/luasnip-nodes.lua create mode 100644 nvim/lua/options.lua create mode 100644 nvim/lua/plugins.lua (limited to 'nvim/lua') diff --git a/nvim/lua/colorscheme.lua b/nvim/lua/colorscheme.lua new file mode 100644 index 0000000..86e8b42 --- /dev/null +++ b/nvim/lua/colorscheme.lua @@ -0,0 +1,18 @@ +require("catppuccin").setup({ + flavour = "macchiato", + background = { + light = "latte", + dark = "macchiato", + }, + custom_highlights = function (colors) + return { + CursorLineNr = { fg = colors.flamingo }, + } + end, + integrations = { + cmp = true, + telescope = true, + }, +}) + +vim.cmd.colorscheme "catppuccin" diff --git a/nvim/lua/commands.lua b/nvim/lua/commands.lua new file mode 100644 index 0000000..8714158 --- /dev/null +++ b/nvim/lua/commands.lua @@ -0,0 +1,10 @@ +vim.api.nvim_create_autocmd("ColorScheme", { + pattern = "*", + callback = function() + package.loaded["feline"] = nil + package.loaded["catppuccin.groups.integrations.feline"] = nil + require("feline").setup { + components = require("catppuccin.groups.integrations.feline").get(), + } + end, +}) diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua new file mode 100644 index 0000000..0b72932 --- /dev/null +++ b/nvim/lua/keymaps.lua @@ -0,0 +1,85 @@ +local map = vim.keymap.set; +local builtin = require('telescope.builtin') +local opts = { noremap = true, silent = true} + +map('', '', 'gk', opts) +map('', '', 'gj', opts) +map('n', 'J', 'mzJ`z', opts) + +map('', 'o', 'o', opts) +map('', 'O', 'O', opts) + +map('i', '', '', opts) +map('v', '', '', opts) +map('t', '', '', opts) +map('v', '', ":m '>+1gv=gv", opts) +map('v', '', ":m '<-2gv=gv", opts) + +map('n', 'Q', '') + +-- +-- telescope +-- +map('n', 'pf', builtin.find_files, {}) +map('n', 'pg', function() + -- If the directory is not a git repository, fallback to regular find_files. + if pcall(builtin.git_files) then + else + pcall(builtin.find_files) + end +end, {}) +map('n', 'fs', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end, {}) +-- + +map("n", "-", "Oil", { desc = "Open parent directory" }) +map('n', 'u', vim.cmd.UndotreeToggle) +map('n', '', vim.cmd.BufferLineCycleNext) +map('n', '', vim.cmd.BufferLineCyclePrev) +map('n', 'br', vim.cmd.BufDel) + +-- +-- window resizing +-- +-- map('n', '', ':vertical resize -2', { silent = true }) +-- map('n', '', ':vertical resize +2', { silent = true }) +-- map('n', '', ':resize +2', { silent = true }) +-- map('n', '', ':resize -2', { silent = true }) + +map('n', '', ':MarkdownPreview', { silent = true }) + +map('x', 'p', '\"_dP') + +map('n', 'y', '\"+y') +map('v', 'y', '\"+y') +map('n', 'Y', '\"+Y') + +map('n', 'd', '\"+d') +map('v', 'd', '\"+d') + +map('n', 'js', ':vertical botright Repl julia') +map('n', 'jr', function() + vim.cmd.ReplSend(string.format('include("%s")', vim.fn.expand('%:p'))) +end) +map('n', 'j;', function() + vim.cmd.ReplSend(string.format('include("%s");', vim.fn.expand('%:p'))) +end) + +map('n', '', vim.cmd.HopWord) + +map('n', 'vv', vim.cmd.VimtexCompile) +map('n', 'vc', ':VimtexClean!') + +map('i', '', [[: silent exec '.!inkscape-figures create "'.getline('.').'" "'.b:vimtex.root.'/figures/"':w]], opts) +map('n', '', [[: silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &':redraw!]], opts) + +vim.cmd([[ +" press to expand or jump in a snippet. These can also be mapped separately +" via luasnip-expand-snippet and luasnip-jump-next. +imap luasnip#expand_or_jumpable() ? 'luasnip-expand-or-jump' : '' +]]) + +map('i', '', [[lua require'luasnip'.jump(-1)]], opts) +map('s', '', [[lua require('luasnip').jump(1)]], opts) +map('s', '', [[lua require('luasnip').jump(-1)]], opts) diff --git a/nvim/lua/luasnip-helpers.lua b/nvim/lua/luasnip-helpers.lua new file mode 100644 index 0000000..e912046 --- /dev/null +++ b/nvim/lua/luasnip-helpers.lua @@ -0,0 +1,41 @@ +local n = require("luasnip-nodes") +local utils = {} + +utils.get_visual = function(args, parent) + if (#parent.snippet.env.LS_SELECT_RAW > 0) then + return n.sn(nil, n.i(1, parent.snippet.env.LS_SELECT_RAW)) + else -- If LS_SELECT_RAW is empty, return a blank insert node + return n.sn(nil, n.i(1)) + end +end + +utils.in_mathzone = function() -- math context detection + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end +utils.in_text = function() + return not utils.in_mathzone() +end +utils.in_comment = function() -- comment detection + return vim.fn['vimtex#syntax#in_comment']() == 1 +end +utils.in_env = function(name) -- generic environment detection + local is_inside = vim.fn['vimtex#env#is_inside'](name) + return (is_inside[1] > 0 and is_inside[2] > 0) +end +-- A few concrete environments---adapt as needed +utils.in_equation = function() -- equation environment detection + return utils.in_env('equation') +end +utils.in_itemize = function() -- itemize environment detection + return utils.in_env('itemize') +end +utils.in_enumerate = function() -- itemize environment detection + return utils.in_env('enumerate') +end +utils.in_tikz = function() -- TikZ picture environment detection + return utils.in_env('tikzpicture') +end + +utils.line_begin = require("luasnip.extras.expand_conditions").line_begin + +return utils diff --git a/nvim/lua/luasnip-nodes.lua b/nvim/lua/luasnip-nodes.lua new file mode 100644 index 0000000..1b48f00 --- /dev/null +++ b/nvim/lua/luasnip-nodes.lua @@ -0,0 +1,31 @@ +local nodes = {} + +local ls = require("luasnip") +local extras = require("luasnip.extras") + +nodes.s = ls.snippet +nodes.sn = ls.snippet_node +nodes.isn = ls.indent_snippet_node +nodes.t = ls.text_node +nodes.i = ls.insert_node +nodes.f = ls.function_node +nodes.c = ls.choice_node +nodes.d = ls.dynamic_node +nodes.r = ls.restore_node +nodes.events = require("luasnip.util.events") +nodes.ai = require("luasnip.nodes.absolute_indexer") +nodes.l = extras.lambda +nodes.rep = extras.rep +nodes.p = extras.partial +nodes.m = extras.match +nodes.n = extras.nonempty +nodes.dl = extras.dynamic_lambda +nodes.fmt = require("luasnip.extras.fmt").fmt +nodes.fmta = require("luasnip.extras.fmt").fmta +nodes.conds = require("luasnip.extras.expand_conditions") +nodes.postfix = require("luasnip.extras.postfix").postfix +nodes.types = require("luasnip.util.types") +nodes.parse = require("luasnip.util.parser").parse_snippet +nodes.ms = ls.multi_snippet + +return nodes diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua new file mode 100644 index 0000000..b555069 --- /dev/null +++ b/nvim/lua/options.lua @@ -0,0 +1,26 @@ +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "no" +vim.opt.cursorline = true +vim.opt.cursorlineopt = "number" +vim.opt.isfname:append("@-@") + +vim.cmd "set undofile" + +vim.g.mapleader = ' ' + +vim.opt.guifont = "FiraCode:h10" diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..2fb9566 --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,74 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + "nvim-tree/nvim-web-devicons", + "ojroques/nvim-bufdel", + "mbbill/undotree", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + 'hrsh7th/nvim-cmp', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'saadparwaiz1/cmp_luasnip', + 'feline-nvim/feline.nvim', + 'tpope/vim-fugitive', + 'axvr/zepl.vim', + 'lervag/vimtex', + 'ixru/nvim-markdown', + 'mg979/vim-visual-multi', + 'stevearc/oil.nvim', + { + 'nvim-telescope/telescope.nvim', tag = '0.1.4', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + { "catppuccin/nvim", name = "catppuccin" }, + { + 'akinsho/bufferline.nvim', version = "*", + dependencies = 'nvim-tree/nvim-web-devicons' + }, + { + "nvim-treesitter/nvim-treesitter", + build = function() + require("nvim-treesitter.install").update({ with_sync = true }) + end, + }, + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp" + }, + { + 'numToStr/Comment.nvim', + opts = { + -- add any options here + }, + lazy = false, + }, + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + ft = { "markdown" }, + build = function() vim.fn["mkdp#util#install"]() end, + }, + { + "smoka7/hop.nvim", + version = "*", + config = function() + require("hop").setup({ keys = "tnseridhaofuwyplcqxz" }) + end, + }, +}) -- cgit v1.3