better in many ways

This commit is contained in:
Solomon Laing 2023-01-09 23:25:14 +10:30
parent 212a138f5d
commit 8795ccaa29
10 changed files with 346 additions and 304 deletions

View File

@ -28,9 +28,12 @@ function M.get_root()
if path then if path then
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
local workspace = client.config.workspace_folders 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) 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 for _, p in ipairs(paths) do
local r = vim.loop.fs_realpath(p) local r = vim.loop.fs_realpath(p)
if path:find(r, 1, true) then if path:find(r, 1, true) then
@ -99,11 +102,11 @@ function M.smart_quit()
prompt = "You have unsaved changes. Quit anyway? (y/n) ", prompt = "You have unsaved changes. Quit anyway? (y/n) ",
}, function(input) }, function(input)
if input == "y" then if input == "y" then
vim.cmd "q!" vim.cmd("q!")
end end
end) end)
else else
vim.cmd "q!" vim.cmd("q!")
end end
end end

View File

@ -2,22 +2,36 @@ return {
{ {
"sainnhe/gruvbox-material", "sainnhe/gruvbox-material",
lazy = true, lazy = true,
priority = 1000,
}, },
{ {
"sainnhe/sonokai", "sainnhe/sonokai",
lazy = true, lazy = true,
priority = 1000,
}, },
{ {
"dracula/vim", "dracula/vim",
lazy = true, lazy = true,
priority = 1000,
}, },
{ {
"RRethy/nvim-base16", "folke/tokyonight.nvim",
lazy = true, lazy = true,
priority = 1000,
},
{
"echasnovski/mini.base16",
lazy = false,
priority = 1000,
},
{
"chriskempson/base16-vim",
lazy = false,
priority = 1000,
}, },
{ {
"NvChad/nvim-colorizer.lua", "NvChad/nvim-colorizer.lua",
config = function() opts = function()
require("colorizer").setup({}) require("colorizer").setup({})
end, end,
}, },

View File

@ -2,7 +2,7 @@ return {
{ {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
event = "BufReadPre", event = "BufReadPre",
config = { opns = {
signs = { signs = {
add = { text = "" }, add = { text = "" },
change = { text = "" }, change = { text = "" },

View File

@ -11,6 +11,7 @@ return {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
}, },
---@type lspconfig.options ---@type lspconfig.options
opts = {
servers = { servers = {
jsonls = {}, jsonls = {},
sumneko_lua = { sumneko_lua = {
@ -26,14 +27,11 @@ return {
}, },
}, },
}, },
-- you can do any additional lsp server setup here setup = {
-- return true if you don't want this server to be setup with lspconfig -- additional setup can be added here.
---@param server string lsp server name },
---@param opts _.lspconfig.options any options set for the server },
setup_server = function(server, opts) config = function(plugin, opts)
return false
end,
config = function(plugin)
-- setup formatting and keymaps -- setup formatting and keymaps
require("lazyvim.functions").on_attach(function(client, buffer) require("lazyvim.functions").on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.format").on_attach(client, buffer) require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
@ -53,18 +51,25 @@ return {
}) })
---@type lspconfig.options ---@type lspconfig.options
local servers = plugin.servers or {} local servers = opts.servers
local capabilities = local capabilities =
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_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({ ensure_installed = vim.tbl_keys(servers) })
require("mason-lspconfig").setup_handlers({ require("mason-lspconfig").setup_handlers({
function(server) function(server)
local opts = servers[server] or {} local server_opts = servers[server] or {}
opts.capabilities = capabilities server_opts.capabilities = capabilities
if not plugin.setup_server(server, opts) then if opts.setup[server] then
require("lspconfig")[server].setup(opts) if opts.setup[server](server, server_opts) then
return
end end
elseif opts.setup["*"] then
if opts.setup["*"](server, server_opts) then
return
end
end
require("lspconfig")[server].setup(server_opts)
end, end,
}) })
end, end,
@ -75,9 +80,9 @@ return {
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
event = "BufReadPre", event = "BufReadPre",
dependencies = { "mason.nvim" }, dependencies = { "mason.nvim" },
config = function() opts = function()
local nls = require("null-ls") local nls = require("null-ls")
nls.setup({ return {
debug = false, debug = false,
sources = { sources = {
nls.builtins.formatting.stylua, nls.builtins.formatting.stylua,
@ -98,7 +103,7 @@ return {
nls.builtins.formatting.beautysh, nls.builtins.formatting.beautysh,
nls.builtins.diagnostics.shellcheck, nls.builtins.diagnostics.shellcheck,
}, },
}) }
end, end,
}, },
@ -107,16 +112,18 @@ return {
"williamboman/mason.nvim", "williamboman/mason.nvim",
cmd = "Mason", cmd = "Mason",
keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } }, keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } },
opts = {
ensure_installed = { ensure_installed = {
"stylua", "stylua",
"shellcheck", "shellcheck",
"shfmt", "shfmt",
"flake8", "flake8",
}, },
config = function(plugin) },
config = function(plugin, opts)
require("mason").setup() require("mason").setup()
local mr = require("mason-registry") 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) local p = mr.get_package(tool)
if not p:is_installed() then if not p:is_installed() then
p:install() p:install()

View File

@ -1,6 +1,7 @@
return { return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
config = function () event = "VeryLazy",
opts = function()
local colors = { local colors = {
red = "#ca1243", red = "#ca1243",
grey = "#a0a1a7", grey = "#a0a1a7",
@ -31,15 +32,14 @@ return {
local function search_result() local function search_result()
if vim.v.hlsearch == 0 then if vim.v.hlsearch == 0 then
return '' return ""
end end
local last_search = vim.fn.getreg('/') local last_search = vim.fn.getreg("/")
if not last_search or last_search == '' then if not last_search or last_search == "" then
return '' return ""
end end
local searchcount = vim.fn.searchcount { maxcount = 9999 } local searchcount = vim.fn.searchcount({ maxcount = 9999 })
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' return last_search .. "(" .. searchcount.current .. "/" .. searchcount.total .. ")"
-- return ""
end end
local function modified() local function modified()
@ -51,17 +51,11 @@ return {
return "" return ""
end end
local status_ok, navic = pcall(require, "nvim-navic") return {
if not status_ok then
print("navic error!")
return
end
require("lualine").setup({
options = { options = {
theme = "gruvbox", theme = "auto",
component_separators = "", globalstatus = true,
section_separators = { left = "", right = "" }, disabled_filetypes = { statusline = { "dashboard", "lazy", "alpha" } },
}, },
sections = process_sections({ sections = process_sections({
lualine_a = { "mode" }, lualine_a = { "mode" },
@ -102,7 +96,14 @@ return {
}, },
}, },
lualine_c = { 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_x = {},
-- lualine_y = { search_result, 'filetype' }, -- lualine_y = { search_result, 'filetype' },
@ -113,6 +114,6 @@ return {
lualine_c = { "%f %y %m" }, lualine_c = { "%f %y %m" },
lualine_x = {}, lualine_x = {},
}, },
}) }
end, end,
} }

View File

@ -2,7 +2,7 @@ return {
{ {
"folke/noice.nvim", "folke/noice.nvim",
event = "VeryLazy", event = "VeryLazy",
config = { opts = {
lsp = { lsp = {
override = { override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true, ["vim.lsp.util.convert_input_to_markdown_lines"] = true,

View File

@ -7,24 +7,35 @@ return {
require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
end, end,
}, },
config = { opts = {
history = true, history = true,
delete_check_events = "TextChanged", delete_check_events = "TextChanged",
}, },
-- stylua: ignore
keys = { keys = {
{ {
"<tab>", "<tab>",
function() function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>" return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end, end,
expr = true, remap = true, silent = true, mode = "i", expr = true,
}, remap = true,
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" }, silent = true,
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, 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" },
},
},
}, },
} }

View File

@ -51,7 +51,7 @@ return {
{ "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" }, { "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" },
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" }, { "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
}, },
config = { opts = {
defaults = { defaults = {
prompt_prefix = "", prompt_prefix = "",
selection_caret = "", selection_caret = "",

View File

@ -2,7 +2,7 @@ return {
{ {
"folke/trouble.nvim", "folke/trouble.nvim",
cmd = { "TroubleToggle", "Trouble" }, cmd = { "TroubleToggle", "Trouble" },
config = { use_diagnostic_signs = true }, opts = { use_diagnostic_signs = true },
keys = { keys = {
{ "<leader>lt", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" }, { "<leader>lt", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
{ "<leader>lT", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" }, { "<leader>lT", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },

View File

@ -1,3 +1,5 @@
local icons = require("lazyvim.config.icons")
return { return {
{ {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
@ -22,9 +24,7 @@ return {
}, },
{ {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
config = function() opts = {
local icons = require("lazyvim.config.icons")
require("notify").setup({
-- Animation style (see below for details) -- Animation style (see below for details)
stages = "fade_in_slide_out", stages = "fade_in_slide_out",
@ -49,8 +49,7 @@ return {
DEBUG = icons.ui.Bug, DEBUG = icons.ui.Bug,
TRACE = icons.ui.Pencil, TRACE = icons.ui.Pencil,
}, },
}) },
end,
}, },
{ {
"echasnovski/mini.bufremove", "echasnovski/mini.bufremove",
@ -60,12 +59,6 @@ return {
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" }, { "<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", "ghillb/cybu.nvim",
keys = { keys = {
@ -111,6 +104,7 @@ return {
}, },
{ {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
event = "BufReadPre",
config = function() config = function()
vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" } vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
vim.g.indent_blankline_filetype_exclude = { vim.g.indent_blankline_filetype_exclude = {
@ -222,4 +216,16 @@ return {
}) })
end, 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 },
},
} }