feat(nvim): debloat setup, tweak lsp

This commit is contained in:
winston 2022-10-18 10:02:19 +02:00
parent a1d56b8afd
commit 8e4e909be2
Signed by: winston
GPG key ID: 3786770EDBC2B481
6 changed files with 407 additions and 385 deletions

View file

@ -1,13 +1,13 @@
-- vim:fdm=marker -- vim:fdm=marker
pcall(require, "impatient") require("impatient")
pcall(require, "plugins") require("plugins")
pcall(require, "lsp") require("lsp")
-- true colors -- true colors
vim.o.termguicolors = true vim.o.termguicolors = true
-- map leader to space -- map leader to space
vim.g.mapleader = " " vim.g.mapleader = " "
vim.o.cmdheight = 0 vim.o.cmdheight = 1
-- line numbers -- line numbers
vim.o.mouse = "" vim.o.mouse = ""
vim.o.number = true vim.o.number = true

View file

@ -1,7 +1,7 @@
require("bufferline").setup({ require("bufferline").setup({
options = { options = {
show_close_icon = false, show_close_icon = false,
separator_style = "slant", separator_style = "thin",
show_buffer_close_icons = false, show_buffer_close_icons = false,
offsets = { { filetype = "NvimTree" } }, offsets = { { filetype = "NvimTree" } },
left_mouse_command = "buffer %d", left_mouse_command = "buffer %d",

View file

@ -1,11 +1,10 @@
local home = os.getenv("HOME")
local db = require("dashboard") local db = require("dashboard")
db.custom_header = function() db.custom_header = function()
local cringe = { local cringe = {
"Have fun coding!", "Have fun coding!",
"Sisyphus wasn't forbidden to smile.", "neovim got rid of the :smile command.",
"Pro tip: Run :q! to exit. Now!", "Pro tip: You can use :q to exit. Do it. Now!",
} }
local random_cringe = cringe[math.random(#cringe)] local random_cringe = cringe[math.random(#cringe)]
return { return {
@ -34,34 +33,48 @@ db.custom_header = function()
} }
end end
local padding = 25
local function pad(string)
local str = string
for _ = 1, padding - #string do
str = str .. " "
end
return str
end
db.custom_center = { db.custom_center = {
{ {
icon = "", icon = "",
desc = "Open Projects ", desc = pad("Open Projects"),
action = "Telescope project", action = "Telescope project",
shortcut = "SPC f p",
}, },
{ {
icon = "", icon = "",
desc = "Find File ", desc = pad("Find File"),
action = "Telescope find_files find_command=rg,--hidden,--files", action = "Telescope find_files find_command=rg,--hidden,--files",
shortcut = "SPC f f",
}, },
{ {
icon = "", icon = "",
desc = "File Browser ", desc = pad("File Browser"),
action = "Telescope file_browser", action = "Telescope file_browser",
shortcut = "SPC f b",
}, },
{ {
icon = "", icon = "",
desc = "Find word ", desc = pad("Find word"),
action = "Telescope live_grep", action = "Telescope live_grep",
shortcut = "SPC f g",
}, },
{ {
icon = "", icon = "",
desc = "Open Settings ", desc = pad("Open Settings"),
action = function() action = function()
vim.cmd("cd " .. home .. "/.config/nvim/") local confpath = vim.fn.resolve(vim.fn.stdpath("config"))
vim.cmd("edit init.lua") require("telescope.builtin").find_files({ cwd = confpath })
end, end,
shortcut = "SPC f s",
}, },
} }

View file

@ -3,10 +3,10 @@ function string.starts(self, str)
end end
local conceal = function() local conceal = function()
local home = os.getenv("HOME") local home = vim.fn.expand("$HOME") .. "/Code/"
local blacklist = { local blacklist = {
[home .. "/git/work"] = "Using nvim at work.", [vim.fn.resolve(home .. "work")] = "Using nvim at work.",
[home .. "/git/freelance"] = "Using nvim to freelance.", [vim.fn.resolve(home .. "freelance")] = "Using nvim to freelance.",
[vim.fn.resolve(vim.fn.stdpath("config"))] = "Stuck in the hell of nvim config.", [vim.fn.resolve(vim.fn.stdpath("config"))] = "Stuck in the hell of nvim config.",
} }

View file

@ -14,10 +14,27 @@ vim.opt.completeopt = "menu,menuone,noselect"
local present, cmp = pcall(require, "cmp") local present, cmp = pcall(require, "cmp")
if not present or not cmp then if not present or not cmp then
vim.pretty_print("cmp not found")
return return
end end
local has_words_before = function()
local line, col = table.unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api
.nvim_buf_get_lines(0, line - 1, line, true)[1]
:sub(col, col)
:match("%s")
== nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes(key, true, true, true),
mode,
true
)
end
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
@ -29,19 +46,30 @@ cmp.setup({
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert({ 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 }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
-- This little snippet will confirm with tab, and if no entry is selected, will confirm the first item
if cmp.visible() then if cmp.visible() then
local entry = cmp.get_selected_entry() cmp.select_next_item()
if not entry then elseif vim.fn["vsnip#available"](1) == 1 then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) feedkey("<Plug>(vsnip-expand-or-jump)", "")
else elseif has_words_before() then
cmp.confirm() cmp.complete()
end
else else
fallback() fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end end
end, { "i", "s", "c" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
@ -187,6 +215,3 @@ local toggle_formatters = function()
end end
vim.api.nvim_create_user_command("ToggleFormatters", toggle_formatters, {}) vim.api.nvim_create_user_command("ToggleFormatters", toggle_formatters, {})
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())

View file

@ -1,23 +1,4 @@
local ensure_packer = function() local packer = require("packer")
local fn = vim.fn
local install_path = fn.stdpath("data")
.. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
vim.cmd([[packadd packer.nvim]])
return true
end
return false
end
local packer_bootstrap = ensure_packer()
-- auto-compile when lua files in `~/.config/nvim/*` change -- auto-compile when lua files in `~/.config/nvim/*` change
vim.api.nvim_create_autocmd("BufWritePost", { vim.api.nvim_create_autocmd("BufWritePost", {
@ -32,343 +13,346 @@ vim.api.nvim_create_autocmd("BufWritePost", {
end, end,
}) })
return require("packer").startup(function(use) return packer.startup({
-- Packer managing itself function(use)
use("wbthomason/packer.nvim") -- Packer managing itself
-- startup time or some shit use("wbthomason/packer.nvim")
use("lewis6991/impatient.nvim") -- startup time or some shit
use("lewis6991/impatient.nvim")
-- colour scheme -- colour scheme
use({
"catppuccin/nvim",
as = "catppuccin",
run = ":CatppuccinCompile",
config = function()
require("config/catppuccin")
end,
})
-- git gutter
use({
"lewis6991/gitsigns.nvim",
config = function()
require("config/gitsigns")
end,
})
-- rainbow indents
use({
"lukas-reineke/indent-blankline.nvim",
config = function()
require("indent_blankline").setup({
space_char_blankline = " ",
show_current_conext = true,
char_highlight_list = {
"IndentBlanklineIndent1",
"IndentBlanklineIndent2",
"IndentBlanklineIndent3",
"IndentBlanklineIndent4",
"IndentBlanklineIndent5",
"IndentBlanklineIndent6",
},
})
vim.g.indent_blankline_filetype_exclude = {
"dashboard",
"help",
"neogitstatus",
"fugitive",
"packer",
"NvimTree",
"Trouble",
}
end,
})
-- top bar
use({
"akinsho/bufferline.nvim",
config = function()
require("config/bufferline")
end,
})
-- bottom bar
use({
"feline-nvim/feline.nvim",
requires = "kyazdani42/nvim-web-devicons",
after = { "catppuccin" },
config = function()
require("config/feline")
end,
})
-- DJI Osmo
use({
"luukvbaal/stabilize.nvim",
config = function()
require("stabilize").setup()
end,
})
-- syntax
use({
"nvim-treesitter/nvim-treesitter",
run = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
config = function()
require("config/treesitter")
end,
})
use({
"p00f/nvim-ts-rainbow",
requires = "nvim-treesitter/nvim-treesitter",
})
-- show possible key combos
use({
"folke/which-key.nvim",
config = function()
require("which-key").setup({})
end,
})
-- syntax
use("alker0/chezmoi.vim")
use("ron-rs/ron.vim")
use("elkowar/yuck.vim")
-- tooling
use("gpanders/editorconfig.nvim")
-- read and write encrypted pgp files
use("jamessan/vim-gnupg")
-- additional functionality
use({
"numToStr/Comment.nvim",
config = function()
require("Comment").setup()
end,
})
use({
"kylechui/nvim-surround",
config = function()
require("nvim-surround").setup({})
end,
})
use("ggandor/lightspeed.nvim")
use("windwp/nvim-autopairs")
use({
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup()
end,
})
--
-- git
use("tpope/vim-fugitive")
-- why not both?
use({
"TimUntersberger/neogit",
requires = "nvim-lua/plenary.nvim",
config = function()
Map("n", "<leader>ng", "<Cmd>Neogit<CR>")
end,
})
use("dhruvasagar/vim-table-mode")
use({
"kyazdani42/nvim-tree.lua",
config = function()
require("nvim-tree").setup({ update_cwd = true })
Map("n", "<C-n>", ":NvimTreeToggle<CR>")
end,
})
use({
"nvchad/nvim-colorizer.lua",
config = function()
require("config/colorizer")
end,
})
use({
"simrat39/symbols-outline.nvim",
config = function()
require("symbols-outline").setup()
Map("n", "<leader>so", ":SymbolsOutline<CR>")
end,
})
-- databases
use("tpope/vim-dadbod")
use("kristijanhusak/vim-dadbod-completion")
use({
"kristijanhusak/vim-dadbod-ui",
config = function()
Map("n", "<leader>db", ":DBUIToggle<CR>")
vim.g.db_ui_use_nerd_fonts = true
vim.g.db_ui_win_position = "right"
end,
})
-- telescope
use({
"nvim-telescope/telescope.nvim",
requires = "nvim-lua/plenary.nvim",
config = function()
Map("n", "<leader>fr", "<cmd>Telescope asynctasks all<CR>")
Map("n", "<leader>fb", "<cmd>Telescope buffers<CR>")
Map("n", "<leader>ff", "<cmd>Telescope find_files<CR>")
Map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>")
Map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>")
end,
})
use({
"nvim-telescope/telescope-fzf-native.nvim",
run = "make",
requires = "nvim-telescope/telescope.nvim",
config = function()
local telescope = require("telescope")
telescope.setup({
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
telescope.load_extension("fzf")
end,
})
use({
"nvim-telescope/telescope-file-browser.nvim",
config = function()
require("telescope").load_extension("file_browser")
end,
})
use({
"nvim-telescope/telescope-project.nvim",
config = function()
require("telescope").load_extension("project")
end,
})
use({
"nvim-telescope/telescope-packer.nvim",
config = function()
require("telescope").load_extension("packer")
end,
})
use({
"andweeb/presence.nvim",
config = function()
require("config/presence")
end,
})
use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install" })
-- external extensions
use("williamboman/mason.nvim")
-- LSP
use("williamboman/mason-lspconfig.nvim")
use("neovim/nvim-lspconfig")
-- completion
use("hrsh7th/nvim-cmp")
use("hrsh7th/cmp-buffer")
use("hrsh7th/cmp-cmdline")
use("hrsh7th/cmp-nvim-lsp")
use("hrsh7th/cmp-path")
use("hrsh7th/cmp-vsnip")
use("hrsh7th/vim-vsnip")
use("petertriho/cmp-git")
use("rafamadriz/friendly-snippets")
use("jose-elias-alvarez/null-ls.nvim")
use({
"glepnir/lspsaga.nvim",
branch = "main",
config = function()
require("config/lspsaga")
end,
})
use("b0o/schemastore.nvim")
use({
"github/copilot.vim",
config = function()
local opt = { noremap = true, silent = true, expr = true }
Map("i", "<C-J>", "copilot#Accept(<Tab>)", opt)
vim.g.copilot_no_tab_map = true
end,
})
-- organization
use({
"vimwiki/vimwiki",
branch = "dev",
config = function()
vim.g.vimwiki_global_ext = 0
vim.g.vimwiki_list = {
{
auto_export = 1,
path = "~/.local/share/vimwiki/",
syntax = "markdown",
ext = ".md",
path_html = "~/vimwiki/",
template_path = "~/.config/vimwiki/templates/",
template_default = "default",
template_ext = ".tpl",
custom_wiki2html = "vimwiki_markdown",
html_filename_parameterization = 1,
},
}
end,
})
use("tools-life/taskwiki")
use({
"skywind3000/asyncrun.vim",
config = function()
vim.g.asyncrun_open = 6
end,
})
use({ "skywind3000/asynctasks.vim" })
use({
"GustavoKatel/telescope-asynctasks.nvim",
config = function()
require("telescope").load_extension("asynctasks")
end,
})
-- startup
use({
"glepnir/dashboard-nvim",
config = function()
require("config/dashboard")
end,
})
-- automatic theme switching
if vim.fn.has("macunix") then
use({ use({
"f-person/auto-dark-mode.nvim", "catppuccin/nvim",
as = "catppuccin",
run = ":CatppuccinCompile",
config = function() config = function()
local auto_dark_mode = require("auto-dark-mode") require("config/catppuccin")
auto_dark_mode.setup({
---@diagnostic disable-next-line: assign-type-mismatch
update_interval = 1000,
set_dark_mode = function()
vim.cmd("Catppuccin frappe")
end,
set_light_mode = function()
vim.cmd("Catppuccin latte")
end,
})
auto_dark_mode.init()
end, end,
}) })
end
if packer_bootstrap then -- git gutter
require("packer").sync() use({
end "lewis6991/gitsigns.nvim",
end) config = function()
require("config/gitsigns")
end,
})
-- rainbow indents
use({
"lukas-reineke/indent-blankline.nvim",
config = function()
require("indent_blankline").setup({
space_char_blankline = " ",
show_current_conext = true,
char_highlight_list = {
"IndentBlanklineIndent1",
"IndentBlanklineIndent2",
"IndentBlanklineIndent3",
"IndentBlanklineIndent4",
"IndentBlanklineIndent5",
"IndentBlanklineIndent6",
},
})
vim.g.indent_blankline_filetype_exclude = {
"dashboard",
"help",
"neogitstatus",
"fugitive",
"packer",
"NvimTree",
"Trouble",
}
end,
})
-- top bar
use({
"akinsho/bufferline.nvim",
config = function()
require("config/bufferline")
end,
})
use({
"nvim-lualine/lualine.nvim",
requires = { "kyazdani42/nvim-web-devicons", opt = true },
config = function()
require("lualine").setup({
options = {
theme = "catppuccin",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_x = {
{
"diagnostics",
sources = { "nvim_lsp" },
-- Displays diagnostics for the defined severity types
sections = { "error", "warn", "info", "hint" },
diagnostics_color = {
-- Same values as the general color option can be used here.
error = "DiagnosticError", -- Changes diagnostics' error color.
warn = "DiagnosticWarn", -- Changes diagnostics' warn color.
info = "DiagnosticInfo", -- Changes diagnostics' info color.
hint = "DiagnosticHint", -- Changes diagnostics' hint color.
},
symbols = { error = "E", warn = "W", info = "I", hint = "H" },
colored = true, -- Displays diagnostics status in color if set to true.
update_in_insert = false, -- Update diagnostics in insert mode.
always_visible = false, -- Show diagnostics even if there are none.
},
},
},
})
end,
})
-- DJI Osmo
use({
"luukvbaal/stabilize.nvim",
config = function()
require("stabilize").setup()
end,
})
-- syntax
use({
"nvim-treesitter/nvim-treesitter",
run = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
config = function()
require("config/treesitter")
end,
})
use({
"p00f/nvim-ts-rainbow",
requires = "nvim-treesitter/nvim-treesitter",
})
-- show possible key combos
use({
"folke/which-key.nvim",
config = function()
require("which-key").setup({})
end,
})
-- syntax
use("alker0/chezmoi.vim")
-- tooling
use("gpanders/editorconfig.nvim")
-- read and write encrypted pgp files
use("jamessan/vim-gnupg")
-- additional functionality
use({
"numToStr/Comment.nvim",
config = function()
require("Comment").setup()
end,
})
use({
"kylechui/nvim-surround",
config = function()
require("nvim-surround").setup({})
end,
})
use("ggandor/lightspeed.nvim")
use({
"windwp/nvim-autopairs",
config = function()
require("nvim-autopairs").setup({})
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
})
use({
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup()
end,
})
-- git
use("tpope/vim-fugitive")
-- why not both?
use({
"TimUntersberger/neogit",
requires = "nvim-lua/plenary.nvim",
config = function()
Map("n", "<leader>ng", "<Cmd>Neogit<CR>")
end,
})
use("dhruvasagar/vim-table-mode")
use({
"nvchad/nvim-colorizer.lua",
config = function()
require("config/colorizer")
end,
})
use({
"simrat39/symbols-outline.nvim",
config = function()
require("symbols-outline").setup()
Map("n", "<leader>so", ":SymbolsOutline<CR>")
end,
})
-- databases
use("tpope/vim-dadbod")
use("kristijanhusak/vim-dadbod-completion")
use({
"kristijanhusak/vim-dadbod-ui",
config = function()
Map("n", "<leader>db", ":DBUIToggle<CR>")
vim.g.db_ui_use_nerd_fonts = true
vim.g.db_ui_win_position = "right"
end,
})
-- telescope
use({
"nvim-telescope/telescope.nvim",
requires = "nvim-lua/plenary.nvim",
config = function()
Map("n", "<leader>fr", "<cmd>Telescope asynctasks all<CR>")
Map("n", "<leader>fb", "<cmd>Telescope file_browser<CR>")
Map("n", "<leader>ff", "<cmd>Telescope find_files<CR>")
Map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>")
Map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>")
Map("n", "<leader>fp", "<cmd>Telescope project<CR>")
Map("n", "<leader>fs", function()
local confpath = vim.fn.resolve(vim.fn.stdpath("config"))
require("telescope.builtin").find_files({ cwd = confpath })
end)
end,
})
use({
"nvim-telescope/telescope-fzf-native.nvim",
run = "make",
requires = "nvim-telescope/telescope.nvim",
config = function()
local telescope = require("telescope")
telescope.setup({
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
telescope.load_extension("fzf")
end,
})
use({
"nvim-telescope/telescope-file-browser.nvim",
config = function()
require("telescope").load_extension("file_browser")
end,
})
use({
"nvim-telescope/telescope-project.nvim",
config = function()
require("telescope").load_extension("project")
end,
})
use({
"andweeb/presence.nvim",
config = function()
require("config/presence")
end,
})
use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install" })
-- LSP
use("williamboman/mason.nvim")
use("williamboman/mason-lspconfig.nvim")
use("neovim/nvim-lspconfig")
-- completion
use("hrsh7th/nvim-cmp")
use("hrsh7th/cmp-buffer")
use("hrsh7th/cmp-cmdline")
use("hrsh7th/cmp-nvim-lsp")
use("hrsh7th/cmp-path")
use("hrsh7th/cmp-vsnip")
use("hrsh7th/vim-vsnip")
use("petertriho/cmp-git")
use("rafamadriz/friendly-snippets")
use("jose-elias-alvarez/null-ls.nvim")
use({
"glepnir/lspsaga.nvim",
branch = "main",
config = function()
require("config/lspsaga")
end,
})
use("b0o/schemastore.nvim")
use({
"github/copilot.vim",
config = function()
local opt = { noremap = true, silent = true, expr = true }
Map("i", "<C-J>", "copilot#Accept(<Tab>)", opt)
vim.g.copilot_no_tab_map = true
end,
})
-- organization
use({
"vimwiki/vimwiki",
branch = "dev",
config = function()
vim.g.vimwiki_global_ext = 0
vim.g.vimwiki_list = {
{
auto_export = 1,
path = "~/.local/share/vimwiki/",
syntax = "markdown",
ext = ".md",
path_html = "~/vimwiki/",
template_path = "~/.config/vimwiki/templates/",
template_default = "default",
template_ext = ".tpl",
custom_wiki2html = "vimwiki_markdown",
html_filename_parameterization = 1,
},
}
end,
})
use("tools-life/taskwiki")
use({
"skywind3000/asyncrun.vim",
config = function()
vim.g.asyncrun_open = 6
end,
})
use({ "skywind3000/asynctasks.vim" })
use({
"GustavoKatel/telescope-asynctasks.nvim",
config = function()
require("telescope").load_extension("asynctasks")
end,
})
-- startup
use({
"glepnir/dashboard-nvim",
config = function()
require("config/dashboard")
end,
})
end,
config = {
display = {
open_fn = require("packer.util").float,
},
},
})