Migrating to Lazy

This commit is contained in:
Eduardo Cueto-Mendoza 2023-08-29 17:33:04 +01:00
parent d465dd1e91
commit 413b072d53
22 changed files with 243 additions and 331 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
*.json *.json
packer_compiled.lua packer_compiled.lua
lua/config/

View File

@ -1,16 +0,0 @@
require("lsp-format").setup {}
local on_attach = function(client)
require("lsp-format").on_attach(client)
-- ... custom code ...
end
require("lspconfig").bashls.setup { on_attach = on_attach }
require("lspconfig").clangd.setup { on_attach = on_attach }
require("lspconfig").julials.setup { on_attach = on_attach }
require("lspconfig").lua_ls.setup { on_attach = on_attach }
require("lspconfig").ltex.setup { on_attach = on_attach }
require("lspconfig").pylsp.setup { on_attach = on_attach }
require("lspconfig").texlab.setup { on_attach = on_attach }
require("lspconfig").zls.setup { on_attach = on_attach }

View File

@ -1,7 +0,0 @@
-- If you want insert `(` after select function or method item
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)

View File

@ -1,5 +0,0 @@
CIFAR
MNIST
LeNet
MUL
BCNN

View File

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

View File

@ -1,10 +0,0 @@
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", "<C-h>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end)

View File

@ -1,122 +0,0 @@
local lsp = require('lsp-zero').preset({})
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
-- Language servers
if (MY_OS == 'Linux')
then
lsp.ensure_installed({
-- Replace these with whatever servers you want to install
'bashls',
'clangd',
'julials',
'lua_ls',
'ltex',
'pylsp',
'texlab',
--'zls'
})
elseif (MY_OS == 'FreeBSD')
then
lsp.ensure_installed({
-- Replace these with whatever servers you want to install
'bashls',
'julials',
'pylsp',
})
else
print('Should never be here')
end
--[[
START LANGUAGE SERVERS CONFIG HERE!!!
]]
--
-- (Optional) Configure lua language server for neovim
require('lspconfig').bashls.setup({})
require('lspconfig').clangd.setup({})
--require('lspconfig').gopls.setup({})
require('lspconfig').julials.setup({})
require('lspconfig').lua_ls.setup({
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { 'vim' },
neededFileStatus = {
["codestyle-check"] = "Any",
},
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
format = {
enable = true,
-- Put format options here
-- NOTE: the value should be STRING!!
defaultConfig = {
indent_style = "space",
indent_size = "4",
}
},
},
},
})
local path = vim.fn.stdpath("config") .. "/after/plugin/dictionary-gb.txt"
local words = {}
for word in io.open(path, "r"):lines() do
table.insert(words, word)
end
require('lspconfig').ltex.setup({
settings = {
ltex = {
language = "en-GB",
dictionary = {
["en-GB"] = words,
},
},
},
})
-- source: https://rust-analyzer.github.io/manual.html#nvim-lsp
--require('lspconfig').rust_analyzer.setup({
-- on_attach = on_attach,
-- settings = {
-- ["rust-analyzer"] = {
-- inlayHints = {
-- closingBraceHints = true, -- Whether to show inlay hints after a closing } to indicate what item it belongs to.
-- }
-- }
-- }
--})
require('lspconfig').texlab.setup({})
require('lspconfig').zls.setup({})
--[[
END LANGUAGE SERVERS CONFIG HERE!!!
]]
--
lsp.setup()

View File

@ -1,6 +0,0 @@
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

@ -1,21 +0,0 @@
require("toggleterm").setup{
-- size can be a number or function which is passed the current terminal
size = 10,
open_mapping = [[<c-t>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
autochdir = false, -- when neovim changes it current directory the terminal will change it's own when next it's opened
shade_terminals = true, -- NOTE: this option takes priority over highlights specified so if you specify Normal highlights you should set this to false
-- shading_factor = '<number>', -- the percentage by which to lighten terminal background, default: -30 (gets multiplied by -3 if background is light)
start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
persist_size = true,
persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered
direction = 'horizontal', -- | 'vertical' | 'tab' | 'float',
close_on_exit = true, -- close the terminal window when the process exits
-- Change the default shell. Can be a string or a function returning a string
shell = vim.o.shell,
auto_scroll = true, -- automatically scroll to the bottom on terminal output
-- This field is only relevant if direction is set to 'float'
}

View File

@ -1,24 +0,0 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "julia", "latex", "lua", "python", "query", "vim", "vimdoc", "zig" },
-- 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,
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
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,
},
}

View File

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

9
init.lua Normal file → Executable file
View File

@ -1,8 +1 @@
require("eddie") require("core")
local f = io.popen("uname -s")
if (f ~= nil) then
MY_OS = f:read("*a")
MY_OS = string.gsub(MY_OS, "%s+", "")
f:close()
end

View File

@ -1,4 +1,3 @@
function ColorMyPencils(color) function ColorMyPencils(color)
color = color or "tokyonight-night" color = color or "tokyonight-night"
vim.cmd.colorscheme(color) vim.cmd.colorscheme(color)
@ -9,3 +8,4 @@ function ColorMyPencils(color)
end end
ColorMyPencils() ColorMyPencils()

View File

@ -0,0 +1,30 @@
require('telescope').setup{
defaults = {
-- Default configuration for telescope goes here:
-- config_key = value,
mappings = {
i = {
-- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key"
}
}
},
pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
},
extensions = {
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
}
}

3
lua/core/init.lua Executable file
View File

@ -0,0 +1,3 @@
require("core.keymaps")
require("core.options")
require("core.lazy")

34
lua/eddie/keymaps.lua → lua/core/keymaps.lua Normal file → Executable file
View File

@ -24,23 +24,23 @@ vim.keymap.set("n", "<BS>", ":bnext<CR>", opts)
vim.keymap.set("n", "<S-TAB>", ":bprevious<CR>", opts) vim.keymap.set("n", "<S-TAB>", ":bprevious<CR>", opts)
-- Telescope -- Telescope
local builtin = require("telescope.builtin") --local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>pf", builtin.find_files, {}) --vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
vim.keymap.set("n", "<C-p>", builtin.git_files, {}) --vim.keymap.set("n", "<C-p>", builtin.git_files, {})
vim.keymap.set("n", "<leader>ps", function () --vim.keymap.set("n", "<leader>ps", function ()
builtin.grep_string( { search = vim.fn.input("Grep > ") } ); -- builtin.grep_string( { search = vim.fn.input("Grep > ") } );
end) --end)
-- Harpoon -- Harpoon
local mark = require("harpoon.mark") --local mark = require("harpoon.mark")
local ui = require("harpoon.ui") --local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file) --vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu) --vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
--
vim.keymap.set("n", "<C-h>", function () ui.nav_file(1) end) --vim.keymap.set("n", "<C-h>", function () ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function () ui.nav_file(2) end) --vim.keymap.set("n", "<C-t>", function () ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function () ui.nav_file(3) end) --vim.keymap.set("n", "<C-n>", function () ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function () ui.nav_file(4) end) --vim.keymap.set("n", "<C-s>", function () ui.nav_file(4) end)
-- Undotree -- Undotree
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle) vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
@ -72,7 +72,3 @@ vim.keymap.set("v", ">", ">gv", opts)
-- Move text on visual mode -- Move text on visual mode
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", opts) vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", opts)
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", opts) vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", opts)

176
lua/core/lazy.lua Executable file
View File

@ -0,0 +1,176 @@
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)
local plugins = {
spec = {
import = "plugins"
},
}
local opts = {
root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed
defaults = {
lazy = false, -- should plugins be lazy-loaded?
version = nil,
-- default `cond` you can use to globally disable a lot of plugins
-- when running inside vscode for example
cond = nil, ---@type boolean|fun(self:LazyPlugin):boolean|nil
-- version = "*", -- enable this to try installing the latest stable versions of plugins
},
-- leave nil when passing the spec as the first argument to setup()
spec = nil, ---@type LazySpec
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
concurrency = jit.os:find("Windows") and (vim.loop.available_parallelism() * 2) or nil, ---@type number limit the maximum amount of concurrent tasks
git = {
-- defaults for the `Lazy log` command
-- log = { "-10" }, -- show the last 10 commits
log = { "-8" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
-- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
-- then set the below to false. This should work, but is NOT supported and will
-- increase downloads a lot.
filter = true,
},
dev = {
-- directory where you store your local plugin projects
path = "~/projects",
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
fallback = false, -- Fallback to git when local plugin doesn't exist
},
install = {
-- install missing plugins on startup. This doesn't increase startup time.
missing = true,
-- try to load one of these colorschemes when starting an installation during startup
colorscheme = { "habamax" },
},
ui = {
-- a number <1 is a percentage., >1 is a fixed size
size = { width = 0.8, height = 0.8 },
wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
-- Show pills on top of the Lazy window
pills = true, ---@type boolean
icons = {
cmd = "",
config = "",
event = "",
ft = "",
init = "",
import = "",
keys = "",
lazy = "󰒲 ",
loaded = "",
not_loaded = "",
plugin = "",
runtime = "",
source = "",
start = "",
task = "",
list = {
"",
"",
"",
"",
},
},
-- leave nil, to automatically select a browser depending on your OS.
-- If you want to use a specific browser, you can define it here
browser = nil, ---@type string?
throttle = 20, -- how frequently should the ui process render events
custom_keys = {
-- you can define custom key maps here.
-- To disable one of the defaults, set it to false
-- open lazygit log
["<localleader>l"] = function(plugin)
require("lazy.util").float_term({ "lazygit", "log" }, {
cwd = plugin.dir,
})
end,
-- open a terminal for the plugin dir
["<localleader>t"] = function(plugin)
require("lazy.util").float_term(nil, {
cwd = plugin.dir,
})
end,
},
},
diff = {
-- diff command <d> can be one of:
-- * browser: opens the github compare view. Note that this is always mapped to <K> as well,
-- so you can have a different command for diff <d>
-- * git: will run git diff and open a buffer with filetype git
-- * terminal_git: will open a pseudo terminal with git diff
-- * diffview.nvim: will open Diffview to show the diff
cmd = "git",
},
checker = {
-- automatically check for plugin updates
enabled = false,
concurrency = nil, ---@type number? set to 1 to check for updates very slowly
notify = true, -- get a notification when new updates are found
frequency = 3600, -- check for updates every hour
},
change_detection = {
-- automatically check for config file changes and reload the ui
enabled = true,
notify = true, -- get a notification when changes are found
},
performance = {
cache = {
enabled = true,
},
reset_packpath = true, -- reset the package path to improve startup time
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
paths = {}, -- add any custom paths here that you want to includes in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
-- "tarPlugin",
-- "tohtml",
-- "tutor",
-- "zipPlugin",
},
},
},
-- lazy can generate helptags from the headings in markdown readme files,
-- so :help works even for plugins that don't have vim docs.
-- when the readme opens with :help it will be correctly displayed as markdown
readme = {
enabled = true,
root = vim.fn.stdpath("state") .. "/lazy/readme",
files = { "README.md", "lua/**/README.md" },
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
},
state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
build = {
-- Plugins can provide a `build.lua` file that will be executed when the plugin is installed
-- or updated. When the plugin spec also has a `build` command, the plugin's `build.lua` not be
-- executed. In this case, a warning message will be shown.
warn_on_override = true,
},
}
require("lazy").setup(plugins, opts)

2
lua/eddie/options.lua → lua/core/options.lua Normal file → Executable file
View File

@ -88,5 +88,3 @@ vim.g.vimtex_log_ignore = ({
"specifier changed to", "specifier changed to",
"Token not allowed in a PDF string", "Token not allowed in a PDF string",
}) })

View File

@ -1,3 +0,0 @@
require("eddie.keymaps")
require("eddie.options")

View File

@ -1,84 +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'
-- Fuzzy Finder
use {
'nvim-telescope/telescope.nvim', tag = '0.1.2',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}
-- Colorscheme
--use({
-- 'rose-pine/neovim',
-- as = 'rose-pine',
-- config = function()
-- vim.cmd('colorscheme rose-pine')
-- end
--})
use { "folke/tokyonight.nvim" }
-- Color Coloring
use({ 'nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' } })
use( 'nvim-treesitter/playground' )
-- Quick access to files
use( 'ThePrimeagen/harpoon' )
-- Recovery
use( 'mbbill/undotree' )
-- Git Status
use( 'tpope/vim-fugitive' )
use('airblade/vim-gitgutter')
-- Language Servers
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
}
}
-- Code formatting
use "lukas-reineke/lsp-format.nvim"
-- Latex on NVIM
use 'lervag/vimtex'
-- :FixWhitespace
use "bronson/vim-trailing-whitespace"
-- Terminal
use {"akinsho/toggleterm.nvim", tag = '*', config = function()
require("toggleterm").setup()
end}
-- Parenthesis complete
use {
"windwp/nvim-autopairs",
config = function() require("nvim-autopairs").setup {} end
}
end)

11
lua/plugins/colorscheme.lua Executable file
View File

@ -0,0 +1,11 @@
return {
{
"folke/tokyonight.nvim",
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
-- load the colorscheme here
require("config.colorscheme")
end,
},
}

View File

@ -0,0 +1,6 @@
-- plugins/telescope.lua:
return {
'nvim-telescope/telescope.nvim', tag = '0.1.2',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' }
}