mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-08-01 16:44:49 +02:00
refactor: move everything under lazyvim
This commit is contained in:
parent
39ccddad5f
commit
8eb8d235c9
17 changed files with 10 additions and 10 deletions
35
lua/lazyvim/config/autocmds.lua
Normal file
35
lua/lazyvim/config/autocmds.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
-- Check if we need to reload the file when it changed
|
||||
vim.api.nvim_create_autocmd("FocusGained", { command = "checktime" })
|
||||
|
||||
-- Highlight on yank
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
||||
|
||||
-- go to last loc when opening a buffer
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
callback = function()
|
||||
vim.cmd([[silent! normal! g`"]])
|
||||
end,
|
||||
})
|
||||
|
||||
-- close some filetypes with <q>
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = {
|
||||
"qf",
|
||||
"help",
|
||||
"man",
|
||||
"notify",
|
||||
"lspinfo",
|
||||
"spectre_panel",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
"PlenaryTestPopup",
|
||||
},
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
|
||||
end,
|
||||
})
|
30
lua/lazyvim/config/icons.lua
Normal file
30
lua/lazyvim/config/icons.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
return {
|
||||
diagnostics = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = " ",
|
||||
Info = " ",
|
||||
},
|
||||
kinds = {
|
||||
Class = " ",
|
||||
Color = " ",
|
||||
Constant = " ",
|
||||
Constructor = " ",
|
||||
Enum = "了 ",
|
||||
EnumMember = " ",
|
||||
Field = " ",
|
||||
File = " ",
|
||||
Folder = " ",
|
||||
Function = " ",
|
||||
Interface = "ﰮ ",
|
||||
Keyword = " ",
|
||||
Method = "ƒ ",
|
||||
Property = " ",
|
||||
Snippet = " ",
|
||||
Struct = " ",
|
||||
Text = " ",
|
||||
Unit = " ",
|
||||
Value = " ",
|
||||
Variable = " ",
|
||||
},
|
||||
}
|
66
lua/lazyvim/config/keymaps.lua
Normal file
66
lua/lazyvim/config/keymaps.lua
Normal file
|
@ -0,0 +1,66 @@
|
|||
-- Move to window using the <meta> movement keys
|
||||
vim.keymap.set("n", "<A-left>", "<C-w>h")
|
||||
vim.keymap.set("n", "<A-down>", "<C-w>j")
|
||||
vim.keymap.set("n", "<A-up>", "<C-w>k")
|
||||
vim.keymap.set("n", "<A-right>", "<C-w>l")
|
||||
|
||||
-- Resize window using <shift> arrow keys
|
||||
vim.keymap.set("n", "<S-Up>", "<cmd>resize +2<CR>")
|
||||
vim.keymap.set("n", "<S-Down>", "<cmd>resize -2<CR>")
|
||||
vim.keymap.set("n", "<S-Left>", "<cmd>vertical resize -2<CR>")
|
||||
vim.keymap.set("n", "<S-Right>", "<cmd>vertical resize +2<CR>")
|
||||
|
||||
-- Move Lines
|
||||
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==")
|
||||
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("i", "<A-j>", "<Esc>:m .+1<CR>==gi")
|
||||
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==")
|
||||
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
|
||||
vim.keymap.set("i", "<A-k>", "<Esc>:m .-2<CR>==gi")
|
||||
|
||||
-- Switch buffers with <ctrl>
|
||||
vim.keymap.set("n", "<C-Left>", "<cmd>bprevious<cr>")
|
||||
vim.keymap.set("n", "<C-Right>", "<cmd>bnext<cr>")
|
||||
|
||||
-- Easier pasting
|
||||
vim.keymap.set("n", "[p", ":pu!<cr>")
|
||||
vim.keymap.set("n", "]p", ":pu<cr>")
|
||||
|
||||
-- Clear search with <esc>
|
||||
vim.keymap.set({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>")
|
||||
vim.keymap.set("n", "gw", "*N")
|
||||
vim.keymap.set("x", "gw", "*N")
|
||||
|
||||
-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n
|
||||
vim.keymap.set("n", "n", "'Nn'[v:searchforward]", { expr = true })
|
||||
vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true })
|
||||
vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true })
|
||||
vim.keymap.set("n", "N", "'nN'[v:searchforward]", { expr = true })
|
||||
vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true })
|
||||
vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true })
|
||||
|
||||
-- Add undo break-points
|
||||
vim.keymap.set("i", ",", ",<c-g>u")
|
||||
vim.keymap.set("i", ".", ".<c-g>u")
|
||||
vim.keymap.set("i", ";", ";<c-g>u")
|
||||
|
||||
-- save in insert mode
|
||||
vim.keymap.set("i", "<C-s>", "<cmd>:w<cr><esc>")
|
||||
vim.keymap.set("n", "<C-s>", "<cmd>:w<cr><esc>")
|
||||
|
||||
-- better indenting
|
||||
vim.keymap.set("v", "<", "<gv")
|
||||
vim.keymap.set("v", ">", ">gv")
|
||||
|
||||
-- lazygit
|
||||
vim.keymap.set("n", "<leader>gg", function()
|
||||
require("lazy.util").open_cmd({ "lazygit" }, {
|
||||
terminal = true,
|
||||
close_on_exit = true,
|
||||
enter = true,
|
||||
float = {
|
||||
size = { width = 0.9, height = 0.9 },
|
||||
margin = { top = 0, right = 0, bottom = 0, left = 0 },
|
||||
},
|
||||
})
|
||||
end, { desc = "Lazygit" })
|
33
lua/lazyvim/config/lazy.lua
Normal file
33
lua/lazyvim/config/lazy.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
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",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup("plugins", {
|
||||
defaults = { lazy = true, version = "*" },
|
||||
install = { colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = { enabled = true },
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
"matchit",
|
||||
"matchparen",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.keymap.set("n", "<leader>l", "<cmd>:Lazy<cr>")
|
54
lua/lazyvim/config/options.lua
Normal file
54
lua/lazyvim/config/options.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
vim.opt.autowrite = true -- enable auto write
|
||||
vim.opt.clipboard = "unnamedplus" -- sync with system clipboard
|
||||
vim.opt.cmdheight = 1
|
||||
vim.opt.completeopt = "menu,menuone,noselect"
|
||||
vim.opt.conceallevel = 3 -- Hide * markup for bold and italic
|
||||
vim.opt.confirm = true -- confirm to save changes before exiting modified buffer
|
||||
vim.opt.cursorline = true -- Enable highlighting of the current line
|
||||
vim.opt.expandtab = true -- Use spaces instead of tabs
|
||||
vim.opt.formatoptions = "jcroqlnt" -- tcqj
|
||||
vim.opt.grepformat = "%f:%l:%c:%m"
|
||||
vim.opt.grepprg = "rg --vimgrep"
|
||||
vim.opt.guifont = "FiraCode Nerd Font:h11"
|
||||
vim.opt.hidden = true -- Enable modified buffers in background
|
||||
vim.opt.ignorecase = true -- Ignore case
|
||||
vim.opt.inccommand = "nosplit" -- preview incremental substitute
|
||||
vim.opt.joinspaces = false -- No double spaces with join after a dot
|
||||
vim.opt.laststatus = 0
|
||||
vim.opt.list = true -- Show some invisible characters (tabs...
|
||||
vim.opt.mouse = "a" -- enable mouse mode
|
||||
vim.opt.number = true -- Print line number
|
||||
vim.opt.pumblend = 10 -- Popup blend
|
||||
vim.opt.pumheight = 10 -- Maximum number of entries in a popup
|
||||
vim.opt.relativenumber = true -- Relative line numbers
|
||||
vim.opt.scrolloff = 4 -- Lines of context
|
||||
vim.opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
|
||||
vim.opt.shiftround = true -- Round indent
|
||||
vim.opt.shiftwidth = 2 -- Size of an indent
|
||||
vim.opt.showmode = false -- dont show mode since we have a statusline
|
||||
vim.opt.sidescrolloff = 8 -- Columns of context
|
||||
vim.opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||
vim.opt.smartcase = true -- Don't ignore case with capitals
|
||||
vim.opt.smartindent = true -- Insert indents automatically
|
||||
vim.opt.spelllang = { "en" }
|
||||
vim.opt.splitbelow = true -- Put new windows below current
|
||||
vim.opt.splitright = true -- Put new windows right of current
|
||||
vim.opt.tabstop = 2 -- Number of spaces tabs count for
|
||||
vim.opt.termguicolors = true -- True color support
|
||||
vim.opt.timeoutlen = 300
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undolevels = 10000
|
||||
vim.opt.updatetime = 200 -- save swap file and trigger CursorHold
|
||||
vim.opt.wildmode = "longest:full,full" -- Command-line completion mode
|
||||
vim.opt.wrap = false -- Disable line wrap
|
||||
|
||||
if vim.fn.has("nvim-0.9.0") == 1 then
|
||||
vim.opt.splitkeep = "screen"
|
||||
vim.o.shortmess = "filnxtToOFWIcC"
|
||||
end
|
||||
|
||||
-- fix markdown indentation settings
|
||||
vim.g.markdown_recommended_style = 0
|
6
lua/lazyvim/plugins/api.lua
Normal file
6
lua/lazyvim/plugins/api.lua
Normal file
|
@ -0,0 +1,6 @@
|
|||
-- plugins that provide apis for other plugins
|
||||
return {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"MunifTanjim/nui.nvim",
|
||||
}
|
83
lua/lazyvim/plugins/coding.lua
Normal file
83
lua/lazyvim/plugins/coding.lua
Normal file
|
@ -0,0 +1,83 @@
|
|||
return {
|
||||
|
||||
-- snippets
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
config = function()
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
-- auto completion
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(_, item)
|
||||
local icons = require("lazyvim.config.icons").kinds
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
return item
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- auto pairs
|
||||
{
|
||||
"echasnovski/mini.pairs",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("mini.pairs").setup({})
|
||||
end,
|
||||
},
|
||||
|
||||
-- comments
|
||||
{ "JoosepAlviste/nvim-ts-context-commentstring" },
|
||||
{
|
||||
"echasnovski/mini.comment",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("mini.comment").setup({
|
||||
hooks = {
|
||||
pre = function()
|
||||
require("ts_context_commentstring.internal").update_commentstring({})
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
21
lua/lazyvim/plugins/colorscheme.lua
Normal file
21
lua/lazyvim/plugins/colorscheme.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
return {
|
||||
|
||||
-- tokyonight
|
||||
{
|
||||
"folke/tokyonight.nvim",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
local tokyonight = require("tokyonight")
|
||||
tokyonight.setup({ style = "moon" })
|
||||
tokyonight.load()
|
||||
end,
|
||||
},
|
||||
|
||||
-- catppuccin
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
priority = 1000,
|
||||
},
|
||||
}
|
130
lua/lazyvim/plugins/editor.lua
Normal file
130
lua/lazyvim/plugins/editor.lua
Normal file
|
@ -0,0 +1,130 @@
|
|||
vim.g.neo_tree_remove_legacy_commands = 1
|
||||
|
||||
return {
|
||||
|
||||
-- file explorer
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
cmd = "Neotree",
|
||||
keys = { { "<leader>ft", "<cmd>Neotree toggle<cr>", desc = "NeoTree" } },
|
||||
config = {
|
||||
filesystem = {
|
||||
follow_current_file = true,
|
||||
hijack_netrw_behavior = "open_current",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- fuzzy finder
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ "<leader><space>", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
|
||||
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
|
||||
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
|
||||
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" },
|
||||
{ "<leader>/", "<cmd>Telescope live_grep<cr>", desc = "Find in Files (Grep)" },
|
||||
},
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- easily jump to any location and enhanced f/t motions for Leap
|
||||
{
|
||||
"ggandor/leap.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
{ "ggandor/flit.nvim", config = { labeled_modes = "nv" } },
|
||||
},
|
||||
config = function()
|
||||
require("leap").add_default_mappings()
|
||||
end,
|
||||
},
|
||||
|
||||
-- which-key
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
local wk = require("which-key")
|
||||
wk.setup({
|
||||
show_help = false,
|
||||
plugins = { spelling = true },
|
||||
key_labels = { ["<leader>"] = "SPC" },
|
||||
})
|
||||
wk.register({
|
||||
mode = { "n", "v" },
|
||||
["g"] = { name = "+goto" },
|
||||
["]"] = { name = "+next" },
|
||||
["["] = { name = "+prev" },
|
||||
["<leader>b"] = { name = "+buffer" },
|
||||
["<leader>c"] = { name = "+code" },
|
||||
["<leader>f"] = { name = "+file" },
|
||||
["<leader>g"] = { name = "+git" },
|
||||
["<leader>x"] = { name = "+diagnostics" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- git signs
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "BufReadPre",
|
||||
config = {
|
||||
signs = {
|
||||
add = { text = "▎" },
|
||||
change = { text = "▎" },
|
||||
delete = { text = "契" },
|
||||
topdelete = { text = "契" },
|
||||
changedelete = { text = "▎" },
|
||||
untracked = { text = "▎" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- references
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
require("illuminate").configure({ delay = 200 })
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"]]",
|
||||
function()
|
||||
require("illuminate").goto_next_reference(false)
|
||||
end,
|
||||
desc = "Next Reference",
|
||||
},
|
||||
{
|
||||
"[[",
|
||||
function()
|
||||
require("illuminate").goto_prev_reference(false)
|
||||
end,
|
||||
desc = "Prev Reference",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- buffer remove
|
||||
{
|
||||
"echasnovski/mini.bufremove",
|
||||
keys = {
|
||||
{
|
||||
"<leader>bd",
|
||||
function()
|
||||
require("mini.bufremove").delete(0, false)
|
||||
end,
|
||||
desc = "Delete Buffer",
|
||||
},
|
||||
{
|
||||
"<leader>bD",
|
||||
function()
|
||||
require("mini.bufremove").delete(0, true)
|
||||
end,
|
||||
desc = "Delete Buffer (Force)",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
40
lua/lazyvim/plugins/lsp/format.lua
Normal file
40
lua/lazyvim/plugins/lsp/format.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local M = {}
|
||||
|
||||
M.autoformat = true
|
||||
|
||||
function M.toggle()
|
||||
M.autoformat = not M.autoformat
|
||||
vim.notify(M.autoformat and "Enabled format on save" or "Disabled format on save")
|
||||
end
|
||||
|
||||
function M.format()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local ft = vim.bo[buf].filetype
|
||||
local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0
|
||||
|
||||
vim.lsp.buf.format({
|
||||
bufnr = buf,
|
||||
filter = function(client)
|
||||
if have_nls then
|
||||
return client.name == "null-ls"
|
||||
end
|
||||
return client.name ~= "null-ls"
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function M.on_attach(client, buf)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("LspFormat." .. buf, {}),
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
if M.autoformat then
|
||||
M.format()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
64
lua/lazyvim/plugins/lsp/init.lua
Normal file
64
lua/lazyvim/plugins/lsp/init.lua
Normal file
|
@ -0,0 +1,64 @@
|
|||
local servers = require("lazyvim.plugins.lsp.servers")
|
||||
|
||||
local function on_attach(client, bufnr)
|
||||
require("lazyvim.plugins.lsp.format").on_attach(client, bufnr)
|
||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, bufnr)
|
||||
end
|
||||
|
||||
return {
|
||||
-- lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = "BufReadPre",
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||
{ "folke/neodev.nvim", config = true },
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
config = true,
|
||||
cmd = "Mason",
|
||||
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
|
||||
},
|
||||
{ "williamboman/mason-lspconfig.nvim", config = { automatic_installation = true } },
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function()
|
||||
-- diagnostics
|
||||
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do
|
||||
name = "DiagnosticSign" .. name
|
||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||
end
|
||||
vim.diagnostic.config({
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = { spacing = 4, prefix = "●" },
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- lspconfig
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
for server, opts in pairs(servers) do
|
||||
opts.capabilities = capabilities
|
||||
opts.on_attach = on_attach
|
||||
require("lspconfig")[server].setup(opts)
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
-- formatters
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
event = "BufReadPre",
|
||||
config = function()
|
||||
local nls = require("null-ls")
|
||||
nls.setup({
|
||||
on_attach = on_attach,
|
||||
sources = {
|
||||
-- nls.builtins.formatting.prettierd,
|
||||
nls.builtins.formatting.stylua,
|
||||
nls.builtins.diagnostics.flake8,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
74
lua/lazyvim/plugins/lsp/keymaps.lua
Normal file
74
lua/lazyvim/plugins/lsp/keymaps.lua
Normal file
|
@ -0,0 +1,74 @@
|
|||
local M = {}
|
||||
|
||||
function M.on_attach(client, buffer)
|
||||
local self = M.new(client, buffer)
|
||||
|
||||
self:map("<leader>cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
|
||||
self:map("<leader>cl", "LspInfo", { desc = "Lsp Info" })
|
||||
self:map("<leader>xd", "Telescope diagnostics", { desc = "Telescope Diagnostics" })
|
||||
self:map("gd", "Telescope lsp_definitions", { desc = "Goto Definition" })
|
||||
self:map("gr", "Telescope lsp_references", { desc = "References" })
|
||||
self:map("gD", "Telescope lsp_declarations", { desc = "Goto Declaration" })
|
||||
self:map("gI", "Telescope lsp_implementations", { desc = "Goto Implementation" })
|
||||
self:map("gt", "Telescope lsp_type_definitions", { desc = "Goto Type Definition" })
|
||||
self:map("K", vim.lsp.buf.hover, { desc = "Hover" })
|
||||
self:map("[d", M.diagnostic_goto(true), { desc = "Next Diagnostic" })
|
||||
self:map("]d", M.diagnostic_goto(false), { desc = "Prev Diagnostic" })
|
||||
self:map("]e", M.diagnostic_goto(true, "ERROR"), { desc = "Next Error" })
|
||||
self:map("[e", M.diagnostic_goto(false, "ERROR"), { desc = "Prev Error" })
|
||||
self:map("]w", M.diagnostic_goto(true, "WARNING"), { desc = "Next Warning" })
|
||||
self:map("[w", M.diagnostic_goto(false, "WARNING"), { desc = "Prev Warning" })
|
||||
|
||||
self:map("<C-k>", vim.lsp.buf.signature_help, { desc = "Signature Help", mode = { "i", "n" }, has = "signatureHelp" })
|
||||
self:map("<leader>ca", vim.lsp.buf.code_action, { desc = "Code Action", mode = { "n", "v" }, has = "codeAction" })
|
||||
|
||||
local format = require("lazyvim.plugins.lsp.format").format
|
||||
self:map("<leader>cf", format, { desc = "Format Document", has = "documentFormatting" })
|
||||
self:map("<leader>cf", format, { desc = "Format Range", mode = "v", has = "documentRangeFormatting" })
|
||||
self:map("<leader>cr", M.rename, { expr = true, desc = "Rename", has = "rename" })
|
||||
|
||||
if client.name == "tsserver" and pcall(require, "typescript") then
|
||||
self:map("<leader>co", "TypescriptOrganizeImports", { desc = "Organize Imports" })
|
||||
self:map("<leader>cR", "TypescriptRenameFile", { desc = "Rename File" })
|
||||
end
|
||||
end
|
||||
|
||||
function M.new(client, buffer)
|
||||
return setmetatable({ client = client, buffer = buffer }, { __index = M })
|
||||
end
|
||||
|
||||
function M:has(cap)
|
||||
return self.client.server_capabilities[cap .. "Provider"]
|
||||
end
|
||||
|
||||
function M:map(lhs, rhs, opts)
|
||||
opts = opts or {}
|
||||
if opts.has and not self:has(opts.has) then
|
||||
return
|
||||
end
|
||||
vim.keymap.set(
|
||||
opts.mode or "n",
|
||||
lhs,
|
||||
type(rhs) == "string" and ("<cmd>%s<cr>"):format(rhs) or rhs,
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
{ silent = true, buffer = self.buffer, expr = opts.expr, desc = opts.desc }
|
||||
)
|
||||
end
|
||||
|
||||
function M.rename()
|
||||
if pcall(require, "inc_rename") then
|
||||
return ":IncRename " .. vim.fn.expand("<cword>")
|
||||
else
|
||||
vim.lsp.buf.rename()
|
||||
end
|
||||
end
|
||||
|
||||
function M.diagnostic_goto(next, severity)
|
||||
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
|
||||
severity = severity and vim.diagnostic.severity[severity] or nil
|
||||
return function()
|
||||
go({ severity = severity })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
26
lua/lazyvim/plugins/lsp/servers.lua
Normal file
26
lua/lazyvim/plugins/lsp/servers.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
-- Add any servers here together with their settings
|
||||
---@type lspconfig.options
|
||||
local servers = {
|
||||
bashls = {},
|
||||
clangd = {},
|
||||
cssls = {},
|
||||
tsserver = {},
|
||||
html = {},
|
||||
jsonls = {},
|
||||
pyright = {},
|
||||
yamlls = {},
|
||||
sumneko_lua = {
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return servers
|
32
lua/lazyvim/plugins/treesitter.lua
Normal file
32
lua/lazyvim/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
sync_install = false,
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"help",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
context_commentstring = { enable = true, enable_autocmd = false },
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
122
lua/lazyvim/plugins/ui.lua
Normal file
122
lua/lazyvim/plugins/ui.lua
Normal file
|
@ -0,0 +1,122 @@
|
|||
return {
|
||||
-- better vim.notify
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
init = function()
|
||||
vim.notify = function(...)
|
||||
vim.notify = require("notify")
|
||||
return vim.notify(...)
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
-- better vim.ui
|
||||
{
|
||||
"stevearc/dressing.nvim",
|
||||
event = "VeryLazy",
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- bufferline
|
||||
{
|
||||
"akinsho/nvim-bufferline.lua",
|
||||
event = "BufAdd",
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- statusline
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
config = {
|
||||
options = {
|
||||
globalstatus = true,
|
||||
disabled_filetypes = { statusline = { "lazy", "alpha" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- indent guides for Neovim
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = "BufReadPre",
|
||||
config = {
|
||||
char = "▏",
|
||||
},
|
||||
},
|
||||
|
||||
-- noicer ui
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
config = {
|
||||
lsp = {
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
["vim.lsp.util.stylize_markdown"] = true,
|
||||
},
|
||||
},
|
||||
presets = {
|
||||
bottom_search = true,
|
||||
command_palette = true,
|
||||
long_message_to_split = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- dashboard
|
||||
{
|
||||
"goolord/alpha-nvim",
|
||||
lazy = false,
|
||||
config = function()
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
local logo = [[
|
||||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
||||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
||||
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
|
||||
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
|
||||
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||
]]
|
||||
|
||||
dashboard.section.header.val = vim.split(logo, "\n")
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("f", " " .. " Find file", ":Telescope find_files <CR>"),
|
||||
dashboard.button("n", " " .. " New file", ":ene <BAR> startinsert <CR>"),
|
||||
dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles <CR>"),
|
||||
dashboard.button("g", " " .. " Find text", ":Telescope live_grep <CR>"),
|
||||
dashboard.button("c", " " .. " Config", ":e $MYVIMRC <CR>"),
|
||||
dashboard.button("l", "鈴" .. " Lazy", ":Lazy<CR>"),
|
||||
dashboard.button("q", " " .. " Quit", ":qa<CR>"),
|
||||
}
|
||||
for _, button in ipairs(dashboard.section.buttons.val) do
|
||||
button.opts.hl = "AlphaButtons"
|
||||
button.opts.hl_shortcut = "AlphaShortcut"
|
||||
end
|
||||
dashboard.section.footer.opts.hl = "Type"
|
||||
dashboard.section.header.opts.hl = "AlphaHeader"
|
||||
dashboard.section.buttons.opts.hl = "AlphaButtons"
|
||||
dashboard.opts.layout[1].val = 8
|
||||
|
||||
if vim.o.filetype == "lazy" then
|
||||
-- close and re-open Lazy after showing alpha
|
||||
vim.notify("Missing plugins installed!", vim.log.levels.INFO, { title = "lazy.nvim" })
|
||||
vim.cmd.close()
|
||||
require("alpha").setup(dashboard.opts)
|
||||
require("lazy").show()
|
||||
else
|
||||
require("alpha").setup(dashboard.opts)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyVimStarted",
|
||||
callback = function()
|
||||
local stats = require("lazy").stats()
|
||||
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
|
||||
dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
|
||||
pcall(vim.cmd.AlphaRedraw)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
5
lua/lazyvim/plugins/util.lua
Normal file
5
lua/lazyvim/plugins/util.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
|
||||
-- measure startuptime
|
||||
{ "dstein64/vim-startuptime", cmd = "StartupTime" },
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue