diff options
Diffstat (limited to 'nvim/lua')
| -rw-r--r-- | nvim/lua/colorscheme.lua | 18 | ||||
| -rw-r--r-- | nvim/lua/commands.lua | 10 | ||||
| -rw-r--r-- | nvim/lua/keymaps.lua | 85 | ||||
| -rw-r--r-- | nvim/lua/luasnip-helpers.lua | 41 | ||||
| -rw-r--r-- | nvim/lua/luasnip-nodes.lua | 31 | ||||
| -rw-r--r-- | nvim/lua/options.lua | 26 | ||||
| -rw-r--r-- | nvim/lua/plugins.lua | 74 |
7 files changed, 285 insertions, 0 deletions
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('', '<Up>', 'gk', opts) +map('', '<Down>', 'gj', opts) +map('n', 'J', 'mzJ`z', opts) + +map('', 'o', 'o<Esc>', opts) +map('', 'O', 'O<Esc>', opts) + +map('i', '<C-Space>', '<Esc>', opts) +map('v', '<C-Space>', '<Esc>', opts) +map('t', '<C-Space>', '<C-\\><C-n>', opts) +map('v', '<PageDown>', ":m '>+1<CR>gv=gv", opts) +map('v', '<PageUp>', ":m '<-2<CR>gv=gv", opts) + +map('n', 'Q', '<nop>') + +-- +-- telescope +-- +map('n', '<leader>pf', builtin.find_files, {}) +map('n', '<leader>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', '<leader>fs', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end, {}) +-- + +map("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" }) +map('n', '<leader>u', vim.cmd.UndotreeToggle) +map('n', '<PageUp>', vim.cmd.BufferLineCycleNext) +map('n', '<PageDown>', vim.cmd.BufferLineCyclePrev) +map('n', '<leader>br', vim.cmd.BufDel) + +-- +-- window resizing +-- +-- map('n', '<S-Left>', ':vertical resize -2<CR>', { silent = true }) +-- map('n', '<S-Right>', ':vertical resize +2<CR>', { silent = true }) +-- map('n', '<S-Up>', ':resize +2<CR>', { silent = true }) +-- map('n', '<S-Down>', ':resize -2<CR>', { silent = true }) + +map('n', '<C-p>', ':MarkdownPreview<CR>', { silent = true }) + +map('x', 'p', '\"_dP') + +map('n', '<leader>y', '\"+y') +map('v', '<leader>y', '\"+y') +map('n', '<leader>Y', '\"+Y') + +map('n', '<leader>d', '\"+d') +map('v', '<leader>d', '\"+d') + +map('n', '<leader>js', ':vertical botright Repl julia<CR>') +map('n', '<leader>jr', function() + vim.cmd.ReplSend(string.format('include("%s")', vim.fn.expand('%:p'))) +end) +map('n', '<leader>j;', function() + vim.cmd.ReplSend(string.format('include("%s");', vim.fn.expand('%:p'))) +end) + +map('n', '<C-h>', vim.cmd.HopWord) + +map('n', '<leader>vv', vim.cmd.VimtexCompile) +map('n', '<leader>vc', ':VimtexClean!<CR>') + +map('i', '<C-f>', [[<Esc>: silent exec '.!inkscape-figures create "'.getline('.').'" "'.b:vimtex.root.'/figures/"'<CR><CR>:w<CR>]], opts) +map('n', '<C-f>', [[: silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &'<CR><CR>:redraw!<CR>]], opts) + +vim.cmd([[ +" press <Tab> to expand or jump in a snippet. These can also be mapped separately +" via <Plug>luasnip-expand-snippet and <Plug>luasnip-jump-next. +imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>' +]]) + +map('i', '<S-Tab>', [[<cmd>lua require'luasnip'.jump(-1)<Cr>]], opts) +map('s', '<Tab>', [[<cmd>lua require('luasnip').jump(1)<Cr>]], opts) +map('s', '<Tab>', [[<cmd>lua require('luasnip').jump(-1)<Cr>]], 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, + }, +}) |