work in progress, migrating to lazy

This commit is contained in:
2024-09-10 17:25:08 +02:00
parent 5d49261bf2
commit 51dfa68847
12 changed files with 79 additions and 53 deletions

View File

@@ -1,3 +1,3 @@
require("flip.packer")
require("flip.remap")
require("flip.set")
require("flip.lazy")

31
lua/flip/lazy.lua Normal file
View File

@@ -0,0 +1,31 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct. This is done by loading the remap before lazy
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import plugins
{ import = "plugins" },
},
-- Configure any other settings here. See documentation for details
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})

View File

@@ -1,52 +0,0 @@
-- This file can be loaded by calling `lua require('plugins')` from your init.vim
-- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use {
'nvim-telescope/telescope.nvim', tag = '0.1.6',
-- or , branch = '0.1.x',
requires = { { 'nvim-lua/plenary.nvim' } }
}
-- Color stuff
use({
'romainl/vim-dichromatic',
config = function()
vim.cmd('colorscheme dichromatic')
end
})
-- Miscellaneous packages that fit on a line
use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' })
use('nvim-treesitter/playground')
use('theprimeagen/harpoon')
use('mbbill/undotree')
use('tpope/vim-fugitive')
-- LSP stuff
use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
requires = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{ -- Optional
'williamboman/mason.nvim',
run = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
}
}
end)

11
lua/plugins/colors.lua Normal file
View File

@@ -0,0 +1,11 @@
function ColorMyPencils(color)
color = color or "dichromatic"
vim.cmd.colorscheme(color)
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
end
vim.keymap.set("n", "<leader>c", function() ColorMyPencils() end)
ColorMyPencils()

9
lua/plugins/harpoon.lua Normal file
View File

@@ -0,0 +1,9 @@
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<leader>1", function() ui.nav_file(1) end)
vim.keymap.set("n", "<leader>2", function() ui.nav_file(2) end)
vim.keymap.set("n", "<leader>3", function() ui.nav_file(3) end)
vim.keymap.set("n", "<leader>4", function() ui.nav_file(4) end)

32
lua/plugins/init.lua Normal file
View File

@@ -0,0 +1,32 @@
-- Load prerequisites for plugins here
return {
{
"nvim-lua/plenary.nvim",
name = "plenary"
}
}
return {
{
"nvim-telescope/telescope.nvim",
tag = "0.1.6",
requires = {
{ "nvim-lua/plenary.nvim" } }
},
{ "romainl/vim-dichromatic", config = function() vim.cmd('colorscheme dichromatic') end },
{
"nvim-treesitter/nvim-treesitter",
build = function()
require("nvim-treesitter.install").update({ with_sync = true })()
end
},
"nvim-treesitter/playground",
"theprimeagen/harpoon",
"mbbill/undotree",
"tpope/vim-fugitive",
{ 'VonHeikemen/lsp-zero.nvim', branch = 'v4.x' },
{ 'neovim/nvim-lspconfig' },
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'hrsh7th/nvim-cmp' },
}

46
lua/plugins/lsp.lua Normal file
View File

@@ -0,0 +1,46 @@
local lsp = require('lsp-zero').preset({})
lsp.ensure_installed({
'lua_ls', -- Lua
'rust_analyzer', -- rust
'texlab', -- LaTeX
'clangd', -- C/C++
'jedi_language_server', -- Python
'html', -- HTML
'ocamllsp', -- OCaml
})
-- Fix undefined global 'vim'
lsp.configure('lua_ls', {
cmd = { 'lua-language-server' },
settings = {
Lua = {
runtime = {
version = 'LuaJIT',
path = vim.split(package.path, ';'),
},
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = {
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
},
},
},
},
})
lsp.on_attach(function(_, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
lsp.set_sign_icons({
error = '',
warn = '',
hint = '',
info = '»'
})
lsp.setup()

View File

@@ -0,0 +1,6 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") });
end)

View File

@@ -0,0 +1,22 @@
require 'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "rust", "cpp", "cmake", "latex", "python", "groovy",
"ocaml" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}

1
lua/plugins/undotree.lua Normal file
View File

@@ -0,0 +1 @@
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)

View File

@@ -0,0 +1 @@
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)