diff --git a/.gitignore b/.gitignore index d699e1d6..b4066687 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -tags -test.sh -.luarc.json +lazy-lock.json nvim diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua new file mode 100644 index 00000000..b641eb1c --- /dev/null +++ b/after/ftplugin/tex.lua @@ -0,0 +1,12 @@ +vim.opt.breakindentopt = "shift:2" +vim.opt.shiftwidth = 4 +vim.opt.textwidth = 0 + + +vim.cmd([[ +function! MyFormatExpr(start, end) + silent execute a:start.','.a:end.'s/[.!?]\zs /\r/g' +endfunction + +set formatexpr=MyFormatExpr(v:lnum,v:lnum+v:count-1) +]]) diff --git a/init.lua b/init.lua index cec3084e..965eec07 100644 --- a/init.lua +++ b/init.lua @@ -1,51 +1,18 @@ ---[[ +-- DISABLED FOR NOW +-- @diagnostic disable: missing-fields -- disables annoying warnings +-- Lua guides: +-- - https://learnxinyminutes.com/docs/lua/ +-- - `:help lua-guide` +-- - https://neovim.io/doc/user/lua-guide.html -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== - -Kickstart.nvim is *not* a distribution. - -Kickstart.nvim is a template for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you should start exploring, configuring and tinkering to - explore Neovim! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example: - - https://learnxinyminutes.com/docs/lua/ - - - And then you can explore or search through `:help lua-guide` - - https://neovim.io/doc/user/lua-guide.html - - -Kickstart Guide: - -I have left several `:help X` comments throughout the init.lua -You should run that command and read that help section for more information. - -In addition, I have some `NOTE:` items throughout the file. -These are for you, the reader to help understand what is happening. Feel free to delete -them once you know what you're doing, but they should serve as a guide for when you -are first encountering a few different constructs in your nvim config. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now :) ---]] --- Set as the leader key --- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' --- Install package manager --- https://github.com/folke/lazy.nvim --- `:help lazy.nvim.txt` for more info + + +vim.g.have_nerd_font = true + local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system { @@ -56,8 +23,8 @@ if not vim.loop.fs_stat(lazypath) then '--branch=stable', -- latest stable release lazypath, } -end -vim.opt.rtp:prepend(lazypath) +end -- ---@diagnostic disable-next-line: undefined-field +vim.opt.runtimepath:prepend(lazypath) -- NOTE: Here is where you install your plugins. -- You can configure plugins using the `config` key. @@ -65,8 +32,6 @@ vim.opt.rtp:prepend(lazypath) -- You can also configure plugins after the setup call, -- as they will be available in your neovim runtime. require('lazy').setup({ - -- NOTE: First, some plugins that don't require any configuration - -- Git related plugins 'tpope/vim-fugitive', 'tpope/vim-rhubarb', @@ -74,8 +39,6 @@ require('lazy').setup({ -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', @@ -86,7 +49,7 @@ require('lazy').setup({ -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', @@ -110,7 +73,7 @@ require('lazy').setup({ }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, + { 'folke/which-key.nvim', opts = {} }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', @@ -124,33 +87,25 @@ require('lazy').setup({ changedelete = { text = '~' }, }, on_attach = function(bufnr) - vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) + vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, + { buffer = bufnr, desc = 'Preview git hunk' }) -- don't override the built-in and fugitive keymaps local gs = package.loaded.gitsigns - vim.keymap.set({'n', 'v'}, ']c', function() + vim.keymap.set({ 'n', 'v' }, ']c', function() if vim.wo.diff then return ']c' end vim.schedule(function() gs.next_hunk() end) return '' - end, {expr=true, buffer = bufnr, desc = "Jump to next hunk"}) - vim.keymap.set({'n', 'v'}, '[c', function() + end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) + vim.keymap.set({ 'n', 'v' }, '[c', function() if vim.wo.diff then return '[c' end vim.schedule(function() gs.prev_hunk() end) return '' - end, {expr=true, buffer = bufnr, desc = "Jump to previous hunk"}) + end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" }) end, }, }, - { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - config = function() - vim.cmd.colorscheme 'onedark' - end, - }, - { -- Set lualine as statusline 'nvim-lualine/lualine.nvim', @@ -158,7 +113,7 @@ require('lazy').setup({ opts = { options = { icons_enabled = false, - theme = 'onedark', + theme = 'catppuccin', component_separators = '|', section_separators = '', }, @@ -212,7 +167,7 @@ require('lazy').setup({ -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.autoformat', -- require 'kickstart.plugins.debug', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -221,22 +176,30 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, {}) -- [[ Setting options ]] -- See `:help vim.o` -- NOTE: You can change these options as you wish! +-- See :help option-list -- Set highlight on search vim.o.hlsearch = false +vim.g.have_nerd_font = true + +-- colorcolumn +vim.o.colorcolumn = "80" + -- Make line numbers default vim.wo.number = true +vim.wo.relativenumber = true -- Enable mouse mode vim.o.mouse = 'a' +vim.opt.showmode = false -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` @@ -274,6 +237,15 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- Remap for dealing with word wrap vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +vim.keymap.set('n', 'gk', "v:count == 0 ? 'k' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'gj', "v:count == 0 ? 'j' : 'j'", { expr = true, silent = true }) + +-- wrap between words +vim.o.linebreak = true +vim.o.expandtab = true +vim.o.shiftwidth = 4 +vim.o.tabstop = 8 +vim.o.softtabstop = 4 -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` @@ -314,18 +286,34 @@ vim.keymap.set('n', '/', function() end, { desc = '[/] Fuzzily search in current buffer' }) vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) +vim.keymap.set('n', 'tf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'th', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'tw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'tg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'td', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'tr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, + ensure_installed = { + 'c', + 'cpp', + 'go', + 'lua', + 'python', + 'rust', + 'tsx', + 'javascript', + 'typescript', + 'vimdoc', + 'vim', + 'latex', + 'haskell', + 'norg', + 'markdown' + }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, @@ -351,8 +339,9 @@ require('nvim-treesitter.configs').setup { ['ia'] = '@parameter.inner', ['af'] = '@function.outer', ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', + -- FUCKS UP VIMTEX COMMANDS! + -- ['ac'] = '@class.outer', + -- ['ic'] = '@class.inner', }, }, move = { @@ -460,6 +449,11 @@ local servers = { telemetry = { enable = false }, }, }, + -- ltex = { + -- ["dictionary"] = { + -- ["en-US"] = { "Surlykke" } + -- } + -- } } -- Setup neovim lua configuration @@ -491,8 +485,17 @@ mason_lspconfig.setup_handlers { -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' -require('luasnip.loaders.from_vscode').lazy_load() -luasnip.config.setup {} +require('luasnip.loaders.from_vscode').lazy_load({ + exclude = { "tex" } +}) +require('luasnip.loaders.from_snipmate').lazy_load({ + exclude = { "tex" } +}) + +luasnip.config.setup { + enable_autosnippets = true, + store_selection_keys = "", +} cmp.setup { snippet = { @@ -503,16 +506,20 @@ cmp.setup { mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, + -- [''] = cmp.mapping.confirm { + -- behavior = cmp.ConfirmBehavior.Replace, + -- select = true, + -- }, [''] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_next_item() + cmp.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + } + -- cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() else @@ -520,9 +527,9 @@ cmp.setup { end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then + -- if cmp.visible() then + -- cmp.select_prev_item() + if luasnip.locally_jumpable(-1) then luasnip.jump(-1) else fallback() @@ -532,6 +539,7 @@ cmp.setup { sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = "neorg" } }, } diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..33874a98 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,5 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = {} +} diff --git a/lua/custom/plugins/colorscheme.lua b/lua/custom/plugins/colorscheme.lua new file mode 100644 index 00000000..7a9de5ce --- /dev/null +++ b/lua/custom/plugins/colorscheme.lua @@ -0,0 +1,20 @@ +return { + { + -- Best colorscheme + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, + config = function() + vim.cmd.colorscheme 'catppuccin' + end, + }, + + { + -- Theme inspired by Atom + 'navarasu/onedark.nvim', + priority = 1000, + -- config = function() + -- vim.cmd.colorscheme 'onedark' + -- end, + }, +} diff --git a/lua/custom/plugins/haskell-tools.lua b/lua/custom/plugins/haskell-tools.lua new file mode 100644 index 00000000..a3c0bd0f --- /dev/null +++ b/lua/custom/plugins/haskell-tools.lua @@ -0,0 +1,5 @@ +return { + 'mrcjkb/haskell-tools.nvim', + version = '^3', -- Recommended + ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' }, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..18fea752 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,8 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +-- +-- FOR PLUGINS NOT REQUIRING CONFIGURATION: +return { + "fladson/vim-kitty" +} diff --git a/lua/custom/plugins/neorg.lua b/lua/custom/plugins/neorg.lua new file mode 100644 index 00000000..619a8113 --- /dev/null +++ b/lua/custom/plugins/neorg.lua @@ -0,0 +1,29 @@ +return { + "nvim-neorg/neorg", + dependencies = { "nvim-lua/plenary.nvim" }, + build = ":Neorg sync-parsers", + -- tag = "*", + lazy = true, -- enable lazy load + ft = "norg", -- lazy load on file type + cmd = "Neorg", -- lazy load on command + config = function() + require("neorg").setup { + load = { + ["core.defaults"] = {}, -- Loads default behaviour + ["core.concealer"] = {}, -- Adds pretty icons to your documents + ["core.dirman"] = { -- Manages Neorg workspaces + config = { + workspaces = { + notes = "~/documents/notes", + }, + }, + }, + ["core.completion"] = { + config = { + engine = "nvim-cmp", + } + } + }, + } + end, +} diff --git a/lua/custom/plugins/rasi.lua b/lua/custom/plugins/rasi.lua new file mode 100644 index 00000000..933415f8 --- /dev/null +++ b/lua/custom/plugins/rasi.lua @@ -0,0 +1,3 @@ +return { + "Fymyte/rasi.vim" +} diff --git a/lua/custom/plugins/sideways.lua b/lua/custom/plugins/sideways.lua new file mode 100644 index 00000000..4f29bbfd --- /dev/null +++ b/lua/custom/plugins/sideways.lua @@ -0,0 +1,9 @@ +return { + "AndrewRadev/sideways.vim", + config = function() + vim.keymap.set("n", "s<", ":SidewaysLeft") + vim.keymap.set("n", "s>", ":SidewaysRight") + vim.keymap.set("n", "sh", ":SidewaysJumpLeft") + vim.keymap.set("n", "sl", ":SidewaysJumpRight") + end, +} diff --git a/lua/custom/plugins/vim-orgmode.lua b/lua/custom/plugins/vim-orgmode.lua new file mode 100644 index 00000000..9b4836f4 --- /dev/null +++ b/lua/custom/plugins/vim-orgmode.lua @@ -0,0 +1,26 @@ +return { + 'nvim-orgmode/orgmode', + dependencies = { + { 'nvim-treesitter/nvim-treesitter', lazy = true }, + }, + -- ADD THIS BACK LATER - SOMETHING WRONG, SO DOESNT START + -- event = 'VeryLazy', + config = function() + -- Load treesitter grammar for org + require('orgmode').setup_ts_grammar() + + -- Setup treesitter + require('nvim-treesitter.configs').setup({ + highlight = { + enable = true, + }, + ensure_installed = { 'org' }, + }) + + -- Setup orgmode + require('orgmode').setup({ + org_agenda_files = '~/documents/orgfiles/**/*', + org_default_notes_file = '~/documents/orgfiles/refile.org', + }) + end, +} diff --git a/lua/custom/plugins/vim-template.lua b/lua/custom/plugins/vim-template.lua new file mode 100644 index 00000000..2a73fc2a --- /dev/null +++ b/lua/custom/plugins/vim-template.lua @@ -0,0 +1,14 @@ +return { + "aperezdc/vim-template", + -- Change init to config, and then tell when to load + -- config only works for lua modules that are "required" by nvim. + init = function() + vim.g.templates_directory = "~/documents/latex-templates/" + vim.g.templates_no_builtin_templates = true + vim.g.templates_global_name_prefix = "template:" + vim.g.templates_name_prefix = "template:" + vim.g.templates_no_autocmd = true + -- vim.cmd("let g:templates_no_autocmd=1") + end, + -- cmd = "Template", +} diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua new file mode 100644 index 00000000..df87fa5c --- /dev/null +++ b/lua/custom/plugins/vimtex.lua @@ -0,0 +1,6 @@ +return { + "lervag/vimtex", + config = function() + vim.g.vimtex_view_method = 'zathura' + end, +} diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua new file mode 100644 index 00000000..04df77b3 --- /dev/null +++ b/lua/kickstart/health.lua @@ -0,0 +1,52 @@ +--[[ +-- +-- This file is not required for your own configuration, +-- but helps people determine if their system is setup correctly. +-- +--]] + +local check_version = function() + local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch) + if not vim.version.cmp then + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + return + end + + if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then + vim.health.ok(string.format("Neovim version is: '%s'", verstr)) + else + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + end +end + +local check_external_reqs = function() + -- Basic utils: `git`, `make`, `unzip` + for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do + local is_executable = vim.fn.executable(exe) == 1 + if is_executable then + vim.health.ok(string.format("Found executable: '%s'", exe)) + else + vim.health.warn(string.format("Could not find executable: '%s'", exe)) + end + end + + return true +end + +return { + check = function() + vim.health.start 'kickstart.nvim' + + vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` + + Fix only warnings for plugins and languages you intend to use. + Mason will give warnings for languages that are not installed. + You do not need to install, unless you want to use those languages!]] + + local uv = vim.uv or vim.loop + vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) + + check_version() + check_external_reqs() + end, +} diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua new file mode 100644 index 00000000..ed7f2693 --- /dev/null +++ b/lua/kickstart/plugins/indent_line.lua @@ -0,0 +1,9 @@ +return { + { -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help ibl` + main = 'ibl', + opts = {}, + }, +} diff --git a/snippets/tex.snippets b/snippets/tex.snippets new file mode 100644 index 00000000..5278f7a6 --- /dev/null +++ b/snippets/tex.snippets @@ -0,0 +1,12 @@ +snippet dmo "\DeclareMathOperator" + \\DeclareMathOperator{${1}}{${2}} + +snippet $$ "$Math$" + \$${1:VISUAL}\$ + +snippet em "\emph{...}" + \emph{${1:VISUAL}} +snippet \ "\[ ... \]" + \[ + ${1} + \]