feat: change to lazyvim
This commit is contained in:
parent
defb419723
commit
3906d422e8
38 changed files with 892 additions and 1541 deletions
137
nvim/lua/plugins/dap.lua
Normal file
137
nvim/lua/plugins/dap.lua
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
return {
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
"jayp0521/mason-nvim-dap.nvim",
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
dap.adapters.lldb = {
|
||||
type = "executable",
|
||||
command = "/usr/bin/lldb-vscode",
|
||||
name = "lldb",
|
||||
}
|
||||
|
||||
local rust_dap = vim.fn.getcwd()
|
||||
local filename = ""
|
||||
for w in rust_dap:gmatch("([^/]+)") do
|
||||
filename = w
|
||||
end
|
||||
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
type = "lldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return rust_dap .. "/target/debug/" .. filename
|
||||
end,
|
||||
--program = '${fileDirname}/${fileBasenameNoExtension}',
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = true,
|
||||
terminal = "integrated",
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "debug cpp",
|
||||
type = "lldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = true,
|
||||
terminal = "integrated",
|
||||
},
|
||||
}
|
||||
dap.configurations.c = dap.configurations.cpp
|
||||
|
||||
require("dapui").setup({
|
||||
icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" },
|
||||
mappings = {
|
||||
-- Use a table to apply multiple mappings
|
||||
expand = { "<CR>", "<2-LeftMouse>" },
|
||||
open = "o",
|
||||
remove = "d",
|
||||
edit = "e",
|
||||
repl = "r",
|
||||
toggle = "t",
|
||||
},
|
||||
-- Expand lines larger than the window
|
||||
-- Requires >= 0.7
|
||||
expand_lines = vim.fn.has("nvim-0.7") == 1,
|
||||
-- Layouts define sections of the screen to place windows.
|
||||
-- The position can be "left", "right", "top" or "bottom".
|
||||
-- The size specifies the height/width depending on position. It can be an Int
|
||||
-- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
|
||||
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
|
||||
-- Elements are the elements shown in the layout (in order).
|
||||
-- Layouts are opened in order so that earlier layouts take priority in window sizing.
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
-- Elements can be strings or table with id and size keys.
|
||||
{ id = "scopes", size = 0.25 },
|
||||
"breakpoints",
|
||||
"stacks",
|
||||
"watches",
|
||||
},
|
||||
size = 40, -- 40 columns
|
||||
position = "left",
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
"repl",
|
||||
"console",
|
||||
},
|
||||
size = 0.25, -- 25% of total lines
|
||||
position = "bottom",
|
||||
},
|
||||
},
|
||||
controls = {
|
||||
-- Requires Neovim nightly (or 0.8 when released)
|
||||
enabled = true,
|
||||
-- Display controls in this element
|
||||
element = "repl",
|
||||
icons = {
|
||||
pause = "",
|
||||
play = "",
|
||||
step_into = "",
|
||||
step_over = "",
|
||||
step_out = "",
|
||||
step_back = "",
|
||||
run_last = "↻",
|
||||
terminate = "□",
|
||||
},
|
||||
},
|
||||
floating = {
|
||||
max_height = nil, -- These can be integers or a float between 0 and 1.
|
||||
max_width = nil, -- Floats will be treated as percentage of your screen.
|
||||
border = "single", -- Border style. Can be "single", "double" or "rounded"
|
||||
mappings = {
|
||||
close = { "q", "<Esc>" },
|
||||
},
|
||||
},
|
||||
windows = { indent = 1 },
|
||||
render = {
|
||||
max_type_length = nil, -- Can be integer or nil.
|
||||
max_value_lines = 100, -- Can be integer or nil.
|
||||
},
|
||||
})
|
||||
|
||||
require("mason-nvim-dap").setup({
|
||||
ensure_installed = {
|
||||
"bash-debug-adapter",
|
||||
"firefox-debug-adapter",
|
||||
"js-debug-adapter",
|
||||
"node-debug2-adapter",
|
||||
},
|
||||
})
|
||||
|
||||
require("nvim-dap-virtual-text").setup()
|
||||
end,
|
||||
},
|
||||
}
|
||||
73
nvim/lua/plugins/dashboard.lua
Normal file
73
nvim/lua/plugins/dashboard.lua
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
return {
|
||||
{
|
||||
"goolord/alpha-nvim",
|
||||
event = "VimEnter",
|
||||
opts = function()
|
||||
local status_ok, alpha = pcall(require, "alpha")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
dashboard.section.header.val = {
|
||||
[[ _______ ___ _______. __ __ __ _______ ]],
|
||||
[[| \ / \ / || | | | | | | ____|]],
|
||||
[[| .--. | / ^ \ | (----`| |__| | | | | |__ ]],
|
||||
[[| | | | / /_\ \ \ \ | __ | | | | __| ]],
|
||||
[[| '--' | / _____ \ .----) | | | | | | | | |____ ]],
|
||||
[[|_______/ /__/ \__\ |_______/ |__| |__| |__| |_______|]],
|
||||
}
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("f", " Find file", ":lua require('telescope.builtin').find_files()<CR>"),
|
||||
dashboard.button(
|
||||
"b",
|
||||
" Open File Browser",
|
||||
":lua require('telescope').extensions.file_browser.file_browser{}<CR>"
|
||||
),
|
||||
dashboard.button("e", " New file", ":ene <BAR> startinsert <CR>"),
|
||||
dashboard.button("p", " Find project", ":lua require('telescope').extensions.project.project{}<CR>"),
|
||||
dashboard.button("r", " Recently used files", ":lua require('telescope.builtin').oldfiles() <CR>"),
|
||||
dashboard.button("t", " Zoxide", ":lua require('telescope').extensions.zoxide.list{}<CR>"),
|
||||
dashboard.button("c", " Configuration", ":e ~/.config/nvim/init.lua <CR>"),
|
||||
dashboard.button("q", " Quit Neovim", ":qa<CR>"),
|
||||
}
|
||||
|
||||
local function footer()
|
||||
return "dashie@dashie.org"
|
||||
end
|
||||
|
||||
dashboard.section.footer.val = footer()
|
||||
|
||||
dashboard.section.footer.opts.hl = "Type"
|
||||
dashboard.section.header.opts.hl = "Include"
|
||||
dashboard.section.buttons.opts.hl = "Keyword"
|
||||
|
||||
dashboard.opts.opts.noautocmd = true
|
||||
alpha.setup(dashboard.opts)
|
||||
end,
|
||||
config = function(_, dashboard)
|
||||
-- close Lazy and re-open when the dashboard is ready
|
||||
if vim.o.filetype == "lazy" then
|
||||
vim.cmd.close()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "AlphaReady",
|
||||
callback = function()
|
||||
require("lazy").show()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
require("alpha").setup(dashboard.opts)
|
||||
|
||||
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,
|
||||
},
|
||||
}
|
||||
145
nvim/lua/plugins/lsp.lua
Normal file
145
nvim/lua/plugins/lsp.lua
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||
{ "folke/neodev.nvim", opts = { experimental = { pathStrict = true } } },
|
||||
"mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
cond = function()
|
||||
return require("lazyvim.util").has("nvim-cmp")
|
||||
end,
|
||||
},
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
-- options for vim.diagnostic.config()
|
||||
diagnostics = {
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = { spacing = 4, prefix = "●" },
|
||||
severity_sort = true,
|
||||
},
|
||||
-- Automatically format on save
|
||||
autoformat = true,
|
||||
-- options for vim.lsp.buf.format
|
||||
-- `bufnr` and `filter` is handled by the LazyVim formatter,
|
||||
-- but can be also overridden when specified
|
||||
format = {
|
||||
formatting_options = nil,
|
||||
timeout_ms = nil,
|
||||
},
|
||||
-- LSP Server Settings
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
jsonls = {},
|
||||
lua_ls = {
|
||||
-- mason = false, -- set to false if you don't want this server to be installed with mason
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
||||
setup = {
|
||||
-- example to setup with typescript.nvim
|
||||
-- tsserver = function(_, opts)
|
||||
-- require("typescript").setup({ server = opts })
|
||||
-- return true
|
||||
-- end,
|
||||
-- Specify * to use this function as a fallback for any server
|
||||
-- ["*"] = function(server, opts) end,
|
||||
},
|
||||
},
|
||||
---@param opts PluginLspOpts
|
||||
config = function(plugin, opts)
|
||||
-- setup autoformat
|
||||
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
|
||||
-- setup formatting and keymaps
|
||||
require("lazyvim.util").on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||
end)
|
||||
|
||||
-- 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(opts.diagnostics)
|
||||
|
||||
require("lsp-inlayhints").setup({})
|
||||
local servers = opts.servers
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
local optslsp = { noremap = false, silent = true, buffer = bufnr }
|
||||
require("lsp-inlayhints").on_attach(client, bufnr)
|
||||
end
|
||||
|
||||
local function setup(server)
|
||||
local server_opts = vim.tbl_deep_extend("force", {
|
||||
capabilities = vim.deepcopy(capabilities),
|
||||
on_attach = on_attach,
|
||||
vim.lsp.diagnostic.on_publish_diagnostics,
|
||||
{
|
||||
-- Disable virtual_text
|
||||
virtual_text = true,
|
||||
},
|
||||
}, servers[server] or {})
|
||||
|
||||
if opts.setup[server] then
|
||||
if opts.setup[server](server, server_opts) then
|
||||
return
|
||||
end
|
||||
elseif opts.setup["*"] then
|
||||
if opts.setup["*"](server, server_opts) then
|
||||
return
|
||||
end
|
||||
end
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
|
||||
-- temp fix for lspconfig rename
|
||||
-- https://github.com/neovim/nvim-lspconfig/pull/2439
|
||||
local mappings = require("mason-lspconfig.mappings.server")
|
||||
if not mappings.lspconfig_to_package.lua_ls then
|
||||
mappings.lspconfig_to_package.lua_ls = "lua-language-server"
|
||||
mappings.package_to_lspconfig["lua-language-server"] = "lua_ls"
|
||||
end
|
||||
|
||||
local mlsp = require("mason-lspconfig")
|
||||
local available = mlsp.get_available_servers()
|
||||
|
||||
local ensure_installed = {} ---@type string[]
|
||||
for server, server_opts in pairs(servers) do
|
||||
if server_opts then
|
||||
server_opts = server_opts == true and {} or server_opts
|
||||
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
|
||||
if server_opts.mason == false or not vim.tbl_contains(available, server) then
|
||||
setup(server)
|
||||
else
|
||||
ensure_installed[#ensure_installed + 1] = server
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup({ ensure_installed = ensure_installed })
|
||||
require("mason-lspconfig").setup_handlers({ setup })
|
||||
vim.cmd([[highlight LspInlayHint guibg=#192330]])
|
||||
end,
|
||||
},
|
||||
}
|
||||
78
nvim/lua/plugins/plugins.lua
Normal file
78
nvim/lua/plugins/plugins.lua
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
return {
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "tokyonight-night",
|
||||
},
|
||||
},
|
||||
{
|
||||
"akinsho/toggleterm.nvim",
|
||||
},
|
||||
{
|
||||
"brenoprata10/nvim-highlight-colors",
|
||||
config = function(_, _)
|
||||
require("nvim-highlight-colors").setup()
|
||||
vim.cmd(":hi clear CursorLine")
|
||||
vim.cmd(":hi clear CursorLineFold")
|
||||
vim.cmd(":hi clear CursorLineSign")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"gpanders/editorconfig.nvim",
|
||||
},
|
||||
{
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
},
|
||||
{
|
||||
"ThePrimeagen/harpoon",
|
||||
config = function()
|
||||
require("telescope").load_extension("harpoon")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"iamcco/markdown-preview.nvim",
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-project.nvim",
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
config = function()
|
||||
require("telescope").load_extension("file_browser")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jvgrootveld/telescope-zoxide",
|
||||
config = function()
|
||||
local z_utils = require("telescope._extensions.zoxide.utils")
|
||||
local t = require("telescope")
|
||||
-- Configure the extension
|
||||
t.setup({
|
||||
extensions = {
|
||||
zoxide = {
|
||||
prompt_title = "[ Queries ]",
|
||||
mappings = {
|
||||
default = {
|
||||
after_action = function(selection)
|
||||
print("Update to (" .. selection.z_score .. ") " .. selection.path)
|
||||
end,
|
||||
},
|
||||
["<C-s>"] = {
|
||||
before_action = function(selection)
|
||||
print("before C-s")
|
||||
end,
|
||||
action = function(selection)
|
||||
vim.cmd("edit " .. selection.path)
|
||||
end,
|
||||
},
|
||||
["<C-q>"] = { action = z_utils.create_basic_command("split") },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Load the extension
|
||||
t.load_extension("zoxide")
|
||||
end,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue