better in many ways
This commit is contained in:
parent
212a138f5d
commit
8795ccaa29
@ -28,9 +28,12 @@ function M.get_root()
|
||||
if path then
|
||||
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||
local workspace = client.config.workspace_folders
|
||||
local paths = workspace and vim.tbl_map(function(ws)
|
||||
local paths = workspace
|
||||
and vim.tbl_map(function(ws)
|
||||
return vim.uri_to_fname(ws.uri)
|
||||
end, workspace) or client.config.root_dir and { client.config.root_dir } or {}
|
||||
end, workspace)
|
||||
or client.config.root_dir and { client.config.root_dir }
|
||||
or {}
|
||||
for _, p in ipairs(paths) do
|
||||
local r = vim.loop.fs_realpath(p)
|
||||
if path:find(r, 1, true) then
|
||||
@ -99,11 +102,11 @@ function M.smart_quit()
|
||||
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
|
||||
}, function(input)
|
||||
if input == "y" then
|
||||
vim.cmd "q!"
|
||||
vim.cmd("q!")
|
||||
end
|
||||
end)
|
||||
else
|
||||
vim.cmd "q!"
|
||||
vim.cmd("q!")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -2,22 +2,36 @@ return {
|
||||
{
|
||||
"sainnhe/gruvbox-material",
|
||||
lazy = true,
|
||||
priority = 1000,
|
||||
},
|
||||
{
|
||||
"sainnhe/sonokai",
|
||||
lazy = true,
|
||||
priority = 1000,
|
||||
},
|
||||
{
|
||||
"dracula/vim",
|
||||
lazy = true,
|
||||
priority = 1000,
|
||||
},
|
||||
{
|
||||
"RRethy/nvim-base16",
|
||||
"folke/tokyonight.nvim",
|
||||
lazy = true,
|
||||
priority = 1000,
|
||||
},
|
||||
{
|
||||
"echasnovski/mini.base16",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
},
|
||||
{
|
||||
"chriskempson/base16-vim",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
},
|
||||
{
|
||||
"NvChad/nvim-colorizer.lua",
|
||||
config = function()
|
||||
opts = function()
|
||||
require("colorizer").setup({})
|
||||
end,
|
||||
},
|
||||
|
||||
@ -2,7 +2,7 @@ return {
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "BufReadPre",
|
||||
config = {
|
||||
opns = {
|
||||
signs = {
|
||||
add = { text = "▎" },
|
||||
change = { text = "▎" },
|
||||
|
||||
@ -11,6 +11,7 @@ return {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
---@type lspconfig.options
|
||||
opts = {
|
||||
servers = {
|
||||
jsonls = {},
|
||||
sumneko_lua = {
|
||||
@ -26,14 +27,11 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@param server string lsp server name
|
||||
---@param opts _.lspconfig.options any options set for the server
|
||||
setup_server = function(server, opts)
|
||||
return false
|
||||
end,
|
||||
config = function(plugin)
|
||||
setup = {
|
||||
-- additional setup can be added here.
|
||||
},
|
||||
},
|
||||
config = function(plugin, opts)
|
||||
-- setup formatting and keymaps
|
||||
require("lazyvim.functions").on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||
@ -53,18 +51,25 @@ return {
|
||||
})
|
||||
|
||||
---@type lspconfig.options
|
||||
local servers = plugin.servers or {}
|
||||
local servers = opts.servers
|
||||
local capabilities =
|
||||
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) })
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(server)
|
||||
local opts = servers[server] or {}
|
||||
opts.capabilities = capabilities
|
||||
if not plugin.setup_server(server, opts) then
|
||||
require("lspconfig")[server].setup(opts)
|
||||
local server_opts = servers[server] or {}
|
||||
server_opts.capabilities = capabilities
|
||||
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,
|
||||
})
|
||||
end,
|
||||
@ -75,9 +80,9 @@ return {
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
event = "BufReadPre",
|
||||
dependencies = { "mason.nvim" },
|
||||
config = function()
|
||||
opts = function()
|
||||
local nls = require("null-ls")
|
||||
nls.setup({
|
||||
return {
|
||||
debug = false,
|
||||
sources = {
|
||||
nls.builtins.formatting.stylua,
|
||||
@ -98,7 +103,7 @@ return {
|
||||
nls.builtins.formatting.beautysh,
|
||||
nls.builtins.diagnostics.shellcheck,
|
||||
},
|
||||
})
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
@ -107,16 +112,18 @@ return {
|
||||
"williamboman/mason.nvim",
|
||||
cmd = "Mason",
|
||||
keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } },
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"flake8",
|
||||
},
|
||||
config = function(plugin)
|
||||
},
|
||||
config = function(plugin, opts)
|
||||
require("mason").setup()
|
||||
local mr = require("mason-registry")
|
||||
for _, tool in ipairs(plugin.ensure_installed) do
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
config = function ()
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
local colors = {
|
||||
red = "#ca1243",
|
||||
grey = "#a0a1a7",
|
||||
@ -31,15 +32,14 @@ return {
|
||||
|
||||
local function search_result()
|
||||
if vim.v.hlsearch == 0 then
|
||||
return ''
|
||||
return ""
|
||||
end
|
||||
local last_search = vim.fn.getreg('/')
|
||||
if not last_search or last_search == '' then
|
||||
return ''
|
||||
local last_search = vim.fn.getreg("/")
|
||||
if not last_search or last_search == "" then
|
||||
return ""
|
||||
end
|
||||
local searchcount = vim.fn.searchcount { maxcount = 9999 }
|
||||
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
|
||||
-- return ""
|
||||
local searchcount = vim.fn.searchcount({ maxcount = 9999 })
|
||||
return last_search .. "(" .. searchcount.current .. "/" .. searchcount.total .. ")"
|
||||
end
|
||||
|
||||
local function modified()
|
||||
@ -51,17 +51,11 @@ return {
|
||||
return ""
|
||||
end
|
||||
|
||||
local status_ok, navic = pcall(require, "nvim-navic")
|
||||
if not status_ok then
|
||||
print("navic error!")
|
||||
return
|
||||
end
|
||||
|
||||
require("lualine").setup({
|
||||
return {
|
||||
options = {
|
||||
theme = "gruvbox",
|
||||
component_separators = "",
|
||||
section_separators = { left = "", right = "" },
|
||||
theme = "auto",
|
||||
globalstatus = true,
|
||||
disabled_filetypes = { statusline = { "dashboard", "lazy", "alpha" } },
|
||||
},
|
||||
sections = process_sections({
|
||||
lualine_a = { "mode" },
|
||||
@ -102,7 +96,14 @@ return {
|
||||
},
|
||||
},
|
||||
lualine_c = {
|
||||
{ navic.get_location, cond = navic.is_available },
|
||||
{
|
||||
function()
|
||||
return require("nvim-navic").get_location()
|
||||
end,
|
||||
cond = function()
|
||||
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
|
||||
end,
|
||||
},
|
||||
},
|
||||
lualine_x = {},
|
||||
-- lualine_y = { search_result, 'filetype' },
|
||||
@ -113,6 +114,6 @@ return {
|
||||
lualine_c = { "%f %y %m" },
|
||||
lualine_x = {},
|
||||
},
|
||||
})
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ return {
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
config = {
|
||||
opts = {
|
||||
lsp = {
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
|
||||
@ -7,24 +7,35 @@ return {
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
end,
|
||||
},
|
||||
config = {
|
||||
opts = {
|
||||
history = true,
|
||||
delete_check_events = "TextChanged",
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{
|
||||
"<tab>",
|
||||
function()
|
||||
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
|
||||
end,
|
||||
expr = true, remap = true, silent = true, mode = "i",
|
||||
},
|
||||
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
|
||||
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
|
||||
},
|
||||
expr = true,
|
||||
remap = true,
|
||||
silent = true,
|
||||
mode = "i",
|
||||
},
|
||||
{
|
||||
"rafamadriz/friendly-snippets", -- collection of useful snippets
|
||||
"<tab>",
|
||||
function()
|
||||
require("luasnip").jump(1)
|
||||
end,
|
||||
mode = "s",
|
||||
},
|
||||
{
|
||||
"<s-tab>",
|
||||
function()
|
||||
require("luasnip").jump(-1)
|
||||
end,
|
||||
mode = { "i", "s" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ return {
|
||||
{ "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" },
|
||||
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
|
||||
},
|
||||
config = {
|
||||
opts = {
|
||||
defaults = {
|
||||
prompt_prefix = " ",
|
||||
selection_caret = " ",
|
||||
|
||||
@ -2,7 +2,7 @@ return {
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
cmd = { "TroubleToggle", "Trouble" },
|
||||
config = { use_diagnostic_signs = true },
|
||||
opts = { use_diagnostic_signs = true },
|
||||
keys = {
|
||||
{ "<leader>lt", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
|
||||
{ "<leader>lT", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
local icons = require("lazyvim.config.icons")
|
||||
|
||||
return {
|
||||
{
|
||||
"nvim-lua/plenary.nvim",
|
||||
@ -22,9 +24,7 @@ return {
|
||||
},
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
config = function()
|
||||
local icons = require("lazyvim.config.icons")
|
||||
require("notify").setup({
|
||||
opts = {
|
||||
-- Animation style (see below for details)
|
||||
stages = "fade_in_slide_out",
|
||||
|
||||
@ -49,8 +49,7 @@ return {
|
||||
DEBUG = icons.ui.Bug,
|
||||
TRACE = icons.ui.Pencil,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
{
|
||||
"echasnovski/mini.bufremove",
|
||||
@ -60,12 +59,6 @@ return {
|
||||
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"lewis6991/impatient.nvim",
|
||||
config = function()
|
||||
require("impatient").enable_profile()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"ghillb/cybu.nvim",
|
||||
keys = {
|
||||
@ -111,6 +104,7 @@ return {
|
||||
},
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = "BufReadPre",
|
||||
config = function()
|
||||
vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
|
||||
vim.g.indent_blankline_filetype_exclude = {
|
||||
@ -222,4 +216,16 @@ return {
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"SmiteshP/nvim-navic",
|
||||
init = function()
|
||||
vim.g.navic_silence = true
|
||||
require("lazyvim.functions").on_attach(function(client, buffer)
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
require("nvim-navic").attach(client, buffer)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
opts = { separator = " ", highlight = true, depth_limit = 5 },
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user