My own first version of kickstart.nvim

This commit is contained in:
AngryLuck 2024-03-19 18:01:42 +01:00
parent 3668af39f4
commit dc41cd1fc2
16 changed files with 305 additions and 93 deletions

4
.gitignore vendored
View File

@ -1,4 +1,2 @@
tags
test.sh
.luarc.json
lazy-lock.json
nvim

12
after/ftplugin/tex.lua Normal file
View File

@ -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)
]])

174
init.lua
View File

@ -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 <space> 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',
@ -124,7 +87,8 @@ require('lazy').setup({
changedelete = { text = '~' },
},
on_attach = function(bufnr)
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' })
vim.keymap.set('n', '<leader>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
@ -142,15 +106,6 @@ require('lazy').setup({
},
},
{
-- 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' }, '<Space>', '<Nop>', { 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', '<leader>/', function()
end, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>tf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>th', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>tw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>tg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>td', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>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 = "<Tab>",
}
cmp.setup {
snippet = {
@ -503,16 +506,20 @@ cmp.setup {
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
-- ['<CR>'] = cmp.mapping.confirm {
-- behavior = cmp.ConfirmBehavior.Replace,
-- select = true,
-- },
['<Tab>'] = 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' }),
['<S-Tab>'] = 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" }
},
}

View File

@ -0,0 +1,5 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
opts = {}
}

View File

@ -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,
},
}

View File

@ -0,0 +1,5 @@
return {
'mrcjkb/haskell-tools.nvim',
version = '^3', -- Recommended
ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' },
}

View File

@ -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"
}

View File

@ -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,
}

View File

@ -0,0 +1,3 @@
return {
"Fymyte/rasi.vim"
}

View File

@ -0,0 +1,9 @@
return {
"AndrewRadev/sideways.vim",
config = function()
vim.keymap.set("n", "<leader>s<", ":SidewaysLeft<Cr>")
vim.keymap.set("n", "<leader>s>", ":SidewaysRight<Cr>")
vim.keymap.set("n", "<leader>sh", ":SidewaysJumpLeft<Cr>")
vim.keymap.set("n", "<leader>sl", ":SidewaysJumpRight<Cr>")
end,
}

View File

@ -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,
}

View File

@ -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",
}

View File

@ -0,0 +1,6 @@
return {
"lervag/vimtex",
config = function()
vim.g.vimtex_view_method = 'zathura'
end,
}

52
lua/kickstart/health.lua Normal file
View File

@ -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,
}

View File

@ -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 = {},
},
}

12
snippets/tex.snippets Normal file
View File

@ -0,0 +1,12 @@
snippet dmo "\DeclareMathOperator"
\\DeclareMathOperator{${1}}{${2}}
snippet $$ "$Math$"
\$${1:VISUAL}\$
snippet em "\emph{...}"
\emph{${1:VISUAL}}
snippet \ "\[ ... \]"
\[
${1}
\]