Skip to content

Instantly share code, notes, and snippets.

@benfrain
Last active February 11, 2024 13:50
Star You must be signed in to star a gist
Save benfrain/97f2b91087121b2d4ba0dcc4202d252f to your computer and use it in GitHub Desktop.
Lua init file for NeoVim 0.9+ (Always a WIP!!)
-- note only needed when working with zmk. goes in the config root.
vim.filetype.add({
extension = {
keymap = "dts",
njk = "html",
},
})
-- Map leader to comma. This lets me do a lot of shortcuts using both hands
vim.g.mapleader = ","
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",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- You will need to install language servers `npm i -g vscode-langservers-extracted` and `npm install -g typescript typescript-language-server`
require("lazy").setup({
spec = "lazySetup",
performance = {
rtp = {
disabled_plugins = {
"gzip",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
ui = {
border = "single",
},
})
require("options")
require("setup.spelling")
require("mappings")
-- returns the require for use in `config` parameter of lazy's use
-- expects the name of the config file
function get_setup(name)
return function()
require("setup." .. name)
end
end
return {
{ "kdheepak/lazygit.nvim" },
{ "kyazdani42/nvim-web-devicons" },
{ "nvim-lua/plenary.nvim" },
{ "rebelot/kanagawa.nvim", config = get_setup("kanagawa"), priority = 1000, lazy = false },
{ "stevearc/dressing.nvim", event = "VeryLazy" },
{ "stevearc/oil.nvim", event = "VeryLazy", config = get_setup("oil") },
{
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
config = get_setup("conform"),
},
{ "mbbill/undotree" },
{ "LudoPinelli/comment-box.nvim", event = "VeryLazy" },
{ "numToStr/Comment.nvim", lazy = false, config = get_setup("Comment") },
{ "rlane/pounce.nvim", config = get_setup("pounce") },
{
"nvim-lualine/lualine.nvim",
config = get_setup("lualine"),
event = "VeryLazy",
},
{
"folke/zen-mode.nvim",
config = get_setup("zen-mode"),
event = "VeryLazy",
},
{
"folke/which-key.nvim",
config = get_setup("which-key"),
event = "VeryLazy",
},
{ "brenoprata10/nvim-highlight-colors", config = get_setup("highlight-colors") },
{
"nvim-treesitter/nvim-treesitter",
config = get_setup("treesitter"),
build = ":TSUpdate",
event = "BufReadPost",
},
{ "rcarriga/nvim-notify" },
{
"hrsh7th/nvim-cmp",
dependencies = {
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "hrsh7th/cmp-cmdline" },
{ "hrsh7th/vim-vsnip" },
{ "hrsh7th/cmp-vsnip" },
{ "hrsh7th/vim-vsnip-integ" },
{ "hrsh7th/cmp-calc" },
{ "hrsh7th/cmp-nvim-lsp-signature-help" },
{ "rafamadriz/friendly-snippets" },
},
config = get_setup("cmp"),
event = "InsertEnter",
},
{
"lewis6991/gitsigns.nvim",
event = "BufReadPre",
config = get_setup("gitsigns"),
},
{ "bennypowers/nvim-ts-autotag", branch = "template-tags", event = "InsertEnter" },
{
"winston0410/range-highlight.nvim",
dependencies = { { "winston0410/cmd-parser.nvim" } },
config = get_setup("range-highlight"),
},
{
"neovim/nvim-lspconfig",
config = get_setup("lsp"),
dependencies = {
"SmiteshP/nvim-navbuddy",
dependencies = {
"SmiteshP/nvim-navic",
"MunifTanjim/nui.nvim",
},
config = get_setup("navbuddy"),
},
},
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
config = get_setup("telescope"),
},
{ "nvim-telescope/telescope-file-browser.nvim" },
{ "rmagatti/auto-session", config = get_setup("auto-session") },
{ "echasnovski/mini.ai", config = get_setup("mini-ai"), version = false },
{ "echasnovski/mini.bracketed", config = get_setup("mini-bracketed"), version = false },
{ "echasnovski/mini.bufremove", config = get_setup("mini-bufremove"), version = false },
{ "echasnovski/mini.indentscope", config = get_setup("mini-indentscope"), version = false, event = "VeryLazy" },
{ "echasnovski/mini.move", config = get_setup("mini-move"), version = false },
{
"windwp/nvim-autopairs",
config = get_setup("autopairs"),
},
{
"kylechui/nvim-surround",
event = "VeryLazy",
config = function()
require("nvim-surround").setup()
end,
},
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = get_setup("headlines"), -- or `opts = {}`
},
{
"rmagatti/session-lens",
dependencies = { "rmagatti/auto-session", "nvim-telescope/telescope.nvim" },
config = get_setup("session"),
enabled = false,
},
{ "goolord/alpha-nvim", config = get_setup("alpha"), enabled = false },
{
"gen740/SmoothCursor.nvim",
config = get_setup("smoothcursor"),
enabled = false,
},
{ "EdenEast/nightfox.nvim", config = get_setup("nightfox"), enabled = false },
{ "folke/tokyonight.nvim", config = get_setup("tokyonight"), enabled = false },
{ "catppuccin/nvim", name = "catppuccin", config = get_setup("catppuccin"), enabled = false },
}
local km = vim.keymap
-- Here is a utility function that closes any floating windows when you press escape
local function close_floating()
for _, win in pairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_get_config(win).relative == "win" then
vim.api.nvim_win_close(win, false)
end
end
end
-- ┌ ┐
-- │ These define common comment styles like this │
-- └ ┘
km.set({ "n", "v" }, "<leader>x1", ":CBlbox12<cr>", { desc = "Comment - single side" })
km.set({ "n", "v" }, "<leader>x2", ":CBlbox18<cr>", { desc = "Comment - both sides" })
km.set("n", "<leader>x3", "CBline3<cr>", { desc = "Centered Line" })
km.set("n", "<leader>x4", "CBline5<cr>", { desc = "Centered Line Weighted" })
km.set("n", "<Leader>u", ":Lazy update<CR>", { desc = "Lazy Update (Sync)" })
km.set("n", "<Leader>n", "<cmd>enew<CR>", { desc = "New File" })
km.set("n", "<Leader>a", "ggVG<c-$>", { desc = "Select All" })
-- Make visual yanks place the cursor back where started
km.set("v", "y", "ygv<Esc>", { desc = "Yank and reposition cursor" })
km.set("n", "<Delete>", "<cmd>:w<CR>", { desc = "Save file" })
km.set("n", "<leader>xu", ":UndotreeToggle<cr>", { desc = "Undo Tree" })
-- More molecular undo of text
km.set("i", ".", ".<c-g>u")
km.set("i", "!", "!<c-g>u")
km.set("i", "?", "?<c-g>u")
km.set("i", ";", ";<c-g>u")
km.set("i", ":", ":<c-g>u")
km.set({ "n", "i" }, "<F1>", "<Esc>")
--nav buddy
km.set({ "n" }, "<leader>xb", ":lua require('nvim-navbuddy').open()<cr>", { desc = "Nav Buddy" })
km.set("n", "<esc>", function()
close_floating()
vim.cmd(":noh")
end, { silent = true, desc = "Remove Search Highlighting, Dismiss Popups" })
km.set("n", "<leader>l", ":LazyGit<cr>", { silent = true, desc = "Lazygit" })
-- Easy delete buffer without losing window split
km.set("n", "<leader>d", ":lua MiniBufremove.delete()<cr>", { silent = true, desc = "Mini Bufremove" })
-- Easy add date/time
function date()
local pos = vim.api.nvim_win_get_cursor(0)[2]
local line = vim.api.nvim_get_current_line()
local nline = line:sub(0, pos) .. "# " .. os.date("%d.%m.%y") .. line:sub(pos + 1)
vim.api.nvim_set_current_line(nline)
vim.api.nvim_feedkeys("o", "n", true)
end
km.set("n", "<Leader>xd", "<cmd>lua date()<cr>", { desc = "Insert Date" })
km.set("n", "<Leader>v", "gea", { desc = "Edit after last word" })
km.set("n", "j", [[(v:count > 5 ? "m'" . v:count : "") . 'j']], { expr = true, desc = "if j > 5 add to jumplist" })
km.set("n", "<leader>p", function()
require("telescope.builtin").find_files()
end, { desc = "Files Find" })
km.set("n", "<leader>r", function()
require("telescope.builtin").registers()
end, { desc = "Browse Registers" })
km.set("n", "<leader>m", function()
require("telescope.builtin").marks()
end, { desc = "Browse Marks" })
km.set("n", "<leader>f", function()
require("telescope.builtin").live_grep()
end, { desc = "Find string" })
km.set("n", "<leader>b", function()
require("telescope.builtin").buffers({
ignore_current_buffer = true,
sort_mru = true,
})
end, { desc = "Browse Buffers" })
km.set("n", "<leader>j", function()
require("telescope.builtin").help_tags()
end, { desc = "Browse Help Tags" })
km.set("n", "<leader>gc", function()
require("telescope.builtin").git_bcommits()
end, { desc = "Browse File Commits" })
km.set("n", "<leader>e", function()
require("telescope").extensions.file_browser.file_browser()
end, { desc = "Files Explore" })
km.set("n", "<leader>s", function()
require("telescope.builtin").spell_suggest(require("telescope.themes").get_cursor({}))
end, { desc = "Spelling Suggestions" })
km.set("n", "<leader>gs", function()
require("telescope.builtin").git_status()
end, { desc = "Git Status" })
km.set("n", "<leader>ca", function()
vim.lsp.buf.code_action()
end, { desc = "Code Actions" })
km.set("n", "<leader>ch", function()
vim.lsp.buf.hover()
end, { desc = "Code Hover" })
km.set("n", "<leader>cl", function()
vim.diagnostic.open_float(0, { scope = "line" })
end, { desc = "Line Diagnostics" })
km.set("n", "<leader>cj", function()
vim.lsp.buf.definition()
end, { desc = "Jump to Definition" })
km.set("n", "<leader>cs", function()
require("telescope.builtin").lsp_document_symbols()
end, { desc = "Code Symbols" })
km.set("n", "<leader>cd", function()
require("telescope.builtin").diagnostics({ bufnr = 0 })
end, { desc = "Code Diagnostics" })
km.set("n", "<leader>cr", function()
require("telescope.builtin").lsp_references()
end, { desc = "Code References" })
km.set({ "v", "n" }, "<leader>cn", function()
vim.lsp.buf.rename()
end, { noremap = true, silent = true, desc = "Code Rename" })
km.set("n", "<Leader><Down>", "<C-W><C-J>", { silent = true, desc = "Window Down" })
km.set("n", "<Leader><Up>", "<C-W><C-K>", { silent = true, desc = "Window Up" })
km.set("n", "<Leader><Right>", "<C-W><C-L>", { silent = true, desc = "Window Right" })
km.set("n", "<Leader><Left>", "<C-W><C-H>", { silent = true, desc = "Window Left" })
km.set("n", "<Leader>wr", "<C-W>R", { silent = true, desc = "Window Resize" })
km.set("n", "<Leader>=", "<C-W>=", { silent = true, desc = "Window Equalise" })
-- Easier window switching with leader + Number
-- Creates mappings like this: km.set("n", "<Leader>2", "2<C-W>w", { desc = "Move to Window 2" })
for i = 1, 6 do
local lhs = "<Leader>" .. i
local rhs = i .. "<C-W>w"
km.set("n", lhs, rhs, { desc = "Move to Window " .. i })
end
km.set({ "n", "v" }, "h", ":Pounce<CR>", { silent = true, desc = "Pounce" })
km.set("n", "H", ":PounceRepeat<CR>", { silent = true, desc = "Pounce Repeat" })
-- thanks to https://www.reddit.com/r/neovim/comments/107g7yf/comment/j3o5a6f/?context=3 we can toggle the line mode changes in our options due to the correct variable being set here
km.set("n", "<leader>z", function()
if vim.g.zen_mode_active then
require("zen-mode").toggle()
vim.g.zen_mode_active = false
else
require("zen-mode").toggle()
vim.g.zen_mode_active = true
end
end, { desc = "Zen Mode Toggle" })
km.set("i", "<A-BS>", "<C-W>", { desc = "Option+BS deletes whole word" })
km.set("n", "<leader>gb", ":Gitsigns toggle_current_line_blame<cr>", { desc = "Git toggle line blame" })
km.set("n", "<Leader>xs", ":SearchSession<CR>", { desc = "Search Sessions" })
km.set(
"v",
"<leader>xp",
":'<,'> w !pandoc --no-highlight --wrap=none | pbcopy <CR>",
{ silent = true, desc = "Pandoc Export" }
)
km.set("n", "<Leader>xn", ":let @+=@%<cr>", { desc = "Copy Buffer name and path" })
km.set("n", "<Leader>xc", ":g/console.lo/d<cr>", { desc = "Remove console.log" })
km.set("v", "<leader>o", "zA", { desc = "Toggle Fold" })
km.set({ "n", "x" }, "[p", '<Cmd>exe "put! " . v:register<CR>', { desc = "Paste Above" })
km.set({ "n", "x" }, "]p", '<Cmd>exe "put " . v:register<CR>', { desc = "Paste Below" })
km.set({ "n", "x" }, "<Bslash>", "<C-6>", { desc = "Alternate File" })
km.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
-- This sets the ability to surround words with brackets and quotes with one key in visual mode
local v_chars = { "(", ")", "[", "]", "{", "}", "'", '"' }
for _, char in pairs(v_chars) do
vim.keymap.set("v", char, "<Plug>(nvim-surround-visual)" .. char)
end
local indent = 4
local opt = vim.opt -- to set options
opt.backspace = { "indent", "eol", "start" }
opt.clipboard = "unnamedplus"
opt.completeopt = "menu,menuone,noselect"
opt.cursorline = true
opt.cursorcolumn = true
opt.encoding = "utf-8" -- Set default encoding to UTF-8
opt.foldenable = true
opt.foldmethod = "manual"
-- opt.formatoptions = "l"
opt.hidden = true -- Enable background buffers
opt.hlsearch = true -- Highlight found searches
opt.ignorecase = true -- Ignore case
opt.inccommand = "split" -- Get a preview of replacements
opt.incsearch = true -- Shows the match while typing
opt.joinspaces = false -- No double spaces with join
vim.o.lazyredraw = true
opt.linebreak = true -- Stop words being broken on wrap
opt.number = true -- Show line numbers
opt.listchars = { tab = "", trail = "·", nbsp = "%" }
opt.list = true -- Show some invisible characters
opt.relativenumber = true
vim.o.shortmess = vim.o.shortmess .. "S" -- stops display of currentsearch match in cmdline area
opt.equalalways = true -- make windows the same width when closing one
opt.cursorlineopt = "both" -- should get cursorline in number too
opt.expandtab = true
opt.shiftwidth = indent
opt.softtabstop = indent
opt.tabstop = indent
opt.showmode = false -- Don't display mode
opt.scrolloff = 999 -- Lines of context
opt.sidescrolloff = 8 -- Columns of context
opt.signcolumn = "yes:1" -- always show signcolumns
opt.smartcase = true -- Do not ignore case with capitals
opt.spelllang = { "en_gb" }
opt.splitbelow = true -- Put new windows below current
opt.splitright = true -- Put new windows right of current
-- opt.splitkeep = "screen" -- Stops screen jumping when splits below are opened
opt.termguicolors = true -- You will have bad experience for diagnostic messages when it's default 4000.
opt.title = true -- Allows neovom to send the Terminal details of the current window, instead of just getting 'v'
-- Give me some fenced codeblock goodness
vim.g.markdown_fenced_languages = { "html", "javascript", "typescript", "css", "scss", "lua", "vim" }
vim.o.whichwrap = vim.o.whichwrap .. "<,>" -- Wrap movement between lines in edit mode with arrows
opt.wrap = true
-- opt.cc = "80"
opt.mouse = "a"
opt.guicursor =
"n-v-c-sm:block-nCursor-blinkwait50-blinkon50-blinkoff50,i-ci-ve:ver25-Cursor-blinkon100-blinkoff100,r-cr-o:hor20"
opt.undodir = vim.fn.stdpath("config") .. "/undo"
opt.undofile = true
vim.notify = require("notify")
opt.jumpoptions = "view"
opt.timeoutlen = 300 -- The time before a key sequence should complete
opt.cpoptions:append(">") -- when you yank multiple times into a register, this puts each on a new line
opt.nrformats:append("alpha") -- this means you can increment lists that have letters with `g ctrl-a`
opt.pumblend = 15 -- partial opacity of pop up menu
opt.ph = 15 -- the number is the number of entries to show before scrollbars, not px!
opt.cmdheight = 0
opt.virtualedit = "block" -- allows using visual blocks beyond the end of a line
local api = vim.api
-- Highlight on yank
local yankGrp = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
api.nvim_create_autocmd("TextYankPost", {
group = yankGrp,
pattern = "*",
callback = function()
vim.highlight.on_yank()
end,
desc = "Highlight yank",
})
-- show cursor line only in active window
local cursorGrp = api.nvim_create_augroup("CursorLine", { clear = true })
api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { pattern = "*", command = "set cursorline", group = cursorGrp })
api.nvim_create_autocmd(
{ "InsertEnter", "WinLeave" },
{ pattern = "*", command = "set nocursorline", group = cursorGrp }
)
-- show cursor col line only in active window
local cursorColGrp = api.nvim_create_augroup("CursorColumn", { clear = true })
api.nvim_create_autocmd(
{ "InsertLeave", "WinEnter" },
{ pattern = "*", command = "set cursorcolumn", group = cursorColGrp }
)
api.nvim_create_autocmd(
{ "InsertEnter", "WinLeave" },
{ pattern = "*", command = "set nocursorcolumn", group = cursorColGrp }
)
-- show Blank Line only in active window
-- local blanklineGrp = api.nvim_create_augroup("BlankLine", { clear = true })
-- api.nvim_create_autocmd(
-- { "InsertLeave", "WinEnter" },
-- { pattern = "*", command = ":IndentBlanklineEnable", group = blanklineGrp }
-- )
-- api.nvim_create_autocmd(
-- { "InsertEnter", "WinLeave" },
-- { pattern = "*", command = ":IndentBlanklineDisable", group = blanklineGrp }
-- )
-- auto-reload files when modified externally
-- https://unix.stackexchange.com/a/383044
vim.o.autoread = true
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, {
command = "if mode() != 'c' | checktime | endif",
pattern = { "*" },
})
-- Don't want relative no on inactive Windows
local relativeNo = api.nvim_create_augroup("RelativeNo", { clear = true })
api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave" }, {
pattern = "*",
group = relativeNo,
callback = function()
if not vim.g.zen_mode_active then
vim.cmd([[set relativenumber]])
end
end,
})
api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter" }, {
pattern = "*",
group = relativeNo,
callback = function()
if not vim.g.zen_mode_active then
vim.cmd([[set norelativenumber]])
end
end,
})
-- This is global settings for diagnostics
vim.o.updatetime = 250
vim.diagnostic.config({
virtual_text = false,
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
})
require("auto-session").setup({
log_level = "error",
})
require("nvim-autopairs").setup({
enable_check_bracket_line = false,
check_ts = true,
enable_after_quote = false,
})
local cmp = require("cmp")
-- local kind_icons = {
-- Text = "",
-- Method = "󰆧",
-- Function = "󰊕",
-- Constructor = "",
-- Field = "󰇽",
-- Variable = "󰂡",
-- Class = "󰠱",
-- Interface = "",
-- Module = "",
-- Property = "󰜢",
-- Unit = "",
-- Value = "󰎠",
-- Enum = "",
-- Keyword = "󰌋",
-- Snippet = "",
-- Color = "󰏘",
-- File = "󰈙",
-- Reference = "",
-- Folder = "󰉋",
-- EnumMember = "",
-- Constant = "󰏿",
-- Struct = "",
-- Event = "",
-- Operator = "󰆕",
-- TypeParameter = "󰅲",
-- }
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
completion = {
completeopt = "menu,menuone,noinsert",
},
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
col_offset = -3,
side_padding = 0,
border = "single",
},
documentation = {
border = "single",
},
},
mapping = {
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), { "i", "c" }),
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
["<CR>"] = cmp.mapping(
cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
{ "i", "c" }
),
},
sources = {
{ name = "nvim_lsp" },
{ name = "vsnip" },
{
name = "buffer",
option = {
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
bufs[vim.api.nvim_win_get_buf(win)] = true
end
return vim.tbl_keys(bufs)
end,
},
},
{ name = "look", keyword_length = 3, option = { convert_case = true, loud = true } },
{ name = "nvim_lua" },
{ name = "calc" },
{ name = "path" },
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
{
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" },
},
},
},
}),
})
cmp.setup.filetype("markdown", {
completion = {
keyword_length = 5,
},
})
-- Customization for Pmenu
vim.api.nvim_set_hl(0, "PmenuSel", { bg = "#282C34", fg = "NONE" })
vim.api.nvim_set_hl(0, "Pmenu", { fg = "#C5CDD9", bg = "#22252A" })
vim.api.nvim_set_hl(0, "CmpItemAbbrDeprecated", { fg = "#7E8294", bg = "NONE", strikethrough = true })
vim.api.nvim_set_hl(0, "CmpItemAbbrMatch", { fg = "#82AAFF", bg = "NONE", bold = true })
vim.api.nvim_set_hl(0, "CmpItemAbbrMatchFuzzy", { fg = "#82AAFF", bg = "NONE", bold = true })
vim.api.nvim_set_hl(0, "CmpItemMenu", { fg = "#C792EA", bg = "NONE", italic = true })
vim.api.nvim_set_hl(0, "CmpItemKindField", { fg = "#EED8DA", bg = "#B5585F" })
vim.api.nvim_set_hl(0, "CmpItemKindProperty", { fg = "#EED8DA", bg = "#B5585F" })
vim.api.nvim_set_hl(0, "CmpItemKindEvent", { fg = "#EED8DA", bg = "#B5585F" })
vim.api.nvim_set_hl(0, "CmpItemKindText", { fg = "#C3E88D", bg = "#9FBD73" })
vim.api.nvim_set_hl(0, "CmpItemKindEnum", { fg = "#C3E88D", bg = "#9FBD73" })
vim.api.nvim_set_hl(0, "CmpItemKindKeyword", { fg = "#C3E88D", bg = "#9FBD73" })
vim.api.nvim_set_hl(0, "CmpItemKindConstant", { fg = "#FFE082", bg = "#D4BB6C" })
vim.api.nvim_set_hl(0, "CmpItemKindConstructor", { fg = "#FFE082", bg = "#D4BB6C" })
vim.api.nvim_set_hl(0, "CmpItemKindReference", { fg = "#FFE082", bg = "#D4BB6C" })
vim.api.nvim_set_hl(0, "CmpItemKindFunction", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindStruct", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindClass", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindModule", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindOperator", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindVariable", { fg = "#C5CDD9", bg = "#7E8294" })
vim.api.nvim_set_hl(0, "CmpItemKindFile", { fg = "#C5CDD9", bg = "#7E8294" })
vim.api.nvim_set_hl(0, "CmpItemKindUnit", { fg = "#F5EBD9", bg = "#D4A959" })
vim.api.nvim_set_hl(0, "CmpItemKindSnippet", { fg = "#F5EBD9", bg = "#D4A959" })
vim.api.nvim_set_hl(0, "CmpItemKindFolder", { fg = "#F5EBD9", bg = "#D4A959" })
vim.api.nvim_set_hl(0, "CmpItemKindMethod", { fg = "#DDE5F5", bg = "#6C8ED4" })
vim.api.nvim_set_hl(0, "CmpItemKindValue", { fg = "#DDE5F5", bg = "#6C8ED4" })
vim.api.nvim_set_hl(0, "CmpItemKindEnumMember", { fg = "#DDE5F5", bg = "#6C8ED4" })
vim.api.nvim_set_hl(0, "CmpItemKindInterface", { fg = "#D8EEEB", bg = "#58B5A8" })
vim.api.nvim_set_hl(0, "CmpItemKindColor", { fg = "#D8EEEB", bg = "#58B5A8" })
vim.api.nvim_set_hl(0, "CmpItemKindTypeParameter", { fg = "#D8EEEB", bg = "#58B5A8" })
require("colorizer").setup({
css = {
RRGGBBAA = true,
css = true,
css_fn = true,
},
html = {
names = false,
},
})
require("Comment").setup({
toggler = {
line = "<C-/>",
block = "<C-?>",
},
opleader = {
line = "<C-/>",
block = "<C-?>",
},
})
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
javascript = { "prettierd", "prettier" },
typescript = { "prettierd", "prettier" },
css = { "prettierd", "prettier" },
scss = { "prettierd", "prettier" },
markdown = { "prettierd", "prettier" },
html = { "prettierd", "prettier" },
json = { "prettierd", "prettier" },
yaml = { "prettierd", "prettier" },
graphql = { "prettierd", "prettier" },
md = { "prettierd", "prettier" },
txt = { "prettierd", "prettier" },
},
formatters = {
stylua = {
args = { "--indent-width", "2", "--indent-type", "Spaces", "-" },
},
},
-- Set up format-on-save
format_on_save = { timeout_ms = 500, lsp_fallback = true },
})
-- gitsigns setup
require("gitsigns").setup({
-- numhl = true,
-- signcolumn = false,
current_line_blame_opts = {
delay = 0,
},
})
vim.cmd([[highlight Headline1 guibg=#2B2B36 guifg=#FF9900 gui=bold]])
vim.cmd([[highlight Headline2 guibg=#262630 guifg=#9EB6F0 gui=bold]])
vim.cmd([[highlight Headline3 guibg=#262630 guifg=#9EB6F0]])
vim.cmd([[highlight CodeBlock guibg=#2C2F44]])
vim.cmd([[highlight Dash guibg=#D19A66 gui=bold]])
require("headlines").setup({
markdown = {
headline_highlights = {
"Headline1",
"Headline2",
"Headline3",
},
},
})
require("nvim-highlight-colors").setup {
render = 'background', -- or 'foreground' or 'first_column'
enable_tailwind = false
}
require("kanagawa").setup({
compile = true,
theme = "wave",
dimInactive = true,
overrides = function(colors)
local theme = colors.theme
local palette = colors.palette
return {
IndentBlanklineChar = { fg = palette.waveBlue2 },
MiniIndentscopeSymbol = { fg = palette.waveBlue2 },
PmenuSel = { blend = 0 },
NormalFloat = { bg = "none" },
FloatBorder = { bg = "none" },
FloatTitle = { bg = "none" },
Visual = { bg = palette.waveBlue2 },
CursorLineNr = { bg = palette.sumiInk5 },
-- Save an hlgroup with dark background and dimmed foreground
-- so that you can use it where your still want darker windows.
-- E.g.: autocmd TermOpen * setlocal winhighlight=Normal:NormalDark
NormalDark = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 },
-- Popular plugins that open floats will link to NormalFloat by default;
-- set their background accordingly if you wish to keep them dark and borderless
LazyNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim },
}
end,
colors = {
theme = {
all = {
ui = {
bg_gutter = "none",
},
},
},
},
})
require("kanagawa").load("wave")
-- LSP this is needed for LSP completions in CSS along with the snippets plugin
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = {
"documentation",
"detail",
"additionalTextEdits",
},
}
-- Give me rounded borders everywhere
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = "rounded"
return orig_util_open_floating_preview(contents, syntax, opts, ...)
end
--Enable (broadcasting) snippet capability for completion
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- LSP Server config
require("lspconfig").cssls.setup({
capabilities = capabilities,
settings = {
scss = {
lint = {
idSelector = "warning",
zeroUnits = "warning",
duplicateProperties = "warning",
},
completion = {
completePropertyWithSemicolon = true,
triggerPropertyValueCompletion = true,
},
},
},
on_attach = function(client)
client.server_capabilities.document_formatting = false
end,
})
require("lspconfig").tsserver.setup({
capabilities = capabilities,
on_attach = function(client)
client.server_capabilities.document_formatting = false
end,
})
require("lspconfig").html.setup({
capabilities = capabilities,
on_attach = function(client)
client.server_capabilities.document_formatting = false
end,
})
require("lspconfig").stylelint_lsp.setup({
filetypes = { "css", "scss" },
root_dir = require("lspconfig").util.root_pattern("package.json", ".git"),
settings = {
stylelintplus = {
-- see available options in stylelint-lsp documentation
},
},
on_attach = function(client)
client.server_capabilities.document_formatting = false
end,
})
-- LSP Prevents inline buffer annotations
vim.diagnostic.open_float()
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = false,
signs = true,
underline = true,
update_on_insert = false,
})
local signs = {
Error = "󰅚 ",
Warn = "󰳦 ",
Hint = "󱡄 ",
Info = "",
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = nil })
end
local function getWords()
if vim.bo.filetype == "md" or vim.bo.filetype == "txt" or vim.bo.filetype == "markdown" then
if vim.fn.wordcount().visual_words == 1 then
return tostring(vim.fn.wordcount().visual_words) .. " word"
elseif not (vim.fn.wordcount().visual_words == nil) then
return tostring(vim.fn.wordcount().visual_words) .. " words"
else
return tostring(vim.fn.wordcount().words) .. " words"
end
else
return ""
end
end
local function place()
local colPre = "C:"
local col = "%c"
local linePre = " L:"
local line = "%l/%L"
return string.format("%s%s%s%s", colPre, col, linePre, line)
end
--- @param trunc_width number trunctates component when screen width is less then trunc_width
--- @param trunc_len number truncates component to trunc_len number of chars
--- @param hide_width number hides component when window width is smaller then hide_width
--- @param no_ellipsis boolean whether to disable adding '...' at end after truncation
--- return function that can format the component accordingly
local function trunc(trunc_width, trunc_len, hide_width, no_ellipsis)
return function(str)
local win_width = vim.fn.winwidth(0)
if hide_width and win_width < hide_width then
return ""
elseif trunc_width and trunc_len and win_width < trunc_width and #str > trunc_len then
return str:sub(1, trunc_len) .. (no_ellipsis and "" or "...")
end
return str
end
end
local function diff_source()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end
local function window()
return vim.api.nvim_win_get_number(0)
end
-- adapted from https://www.reddit.com/r/neovim/comments/xy0tu1/cmdheight0_recording_macros_message/
local function show_macro_recording()
local recording_register = vim.fn.reg_recording()
if recording_register == "" then
return ""
else
return "󰑋 " .. recording_register
end
end
-- print(vim.inspect(nfColors))
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { " ", " " },
section_separators = { left = "", right = "" },
disabled_filetypes = {},
},
sections = {
lualine_a = {
{ "mode", fmt = trunc(80, 1, nil, true) },
},
lualine_b = {
{ "branch", icon = "󰘬" },
{
"diff",
colored = true,
source = diff_source,
diff_color = {
color_added = "#a7c080",
color_modified = "#ffdf1b",
color_removed = "#ff6666",
},
},
},
lualine_c = {
{ "diagnostics", sources = { "nvim_diagnostic" } },
function()
return "%="
end,
{
"filename",
file_status = true,
path = 0,
shorting_target = 40,
symbols = {
modified = "󰐖", -- Text to show when the file is modified.
readonly = "", -- Text to show when the file is non-modifiable or readonly.
unnamed = "[No Name]", -- Text to show for unnamed buffers.
newfile = "[New]", -- Text to show for new created file before first writting
},
},
{
getWords,
color = { fg = "#333333", bg = "#eeeeee" },
separator = { left = "", right = "" },
},
{
"searchcount",
},
{
"selectioncount",
},
{
show_macro_recording,
color = { fg = "#333333", bg = "#ff6666" },
separator = { left = "", right = "" },
},
},
lualine_x = { { "filetype", icon_only = true } },
lualine_y = { { require("auto-session.lib").current_session_name } },
lualine_z = {
{ place, padding = { left = 1, right = 1 } },
},
},
inactive_sections = {
lualine_a = { { window, color = { fg = "#26ffbb", bg = "#282828" } } },
lualine_b = {
{
"diff",
source = diff_source,
color_added = "#a7c080",
color_modified = "#ffdf1b",
color_removed = "#ff6666",
},
},
lualine_c = {
function()
return "%="
end,
{
"filename",
path = 1,
shorting_target = 40,
symbols = {
modified = "󰐖", -- Text to show when the file is modified.
readonly = "", -- Text to show when the file is non-modifiable or readonly.
unnamed = "[No Name]", -- Text to show for unnamed buffers.
newfile = "[New]", -- Text to show for new created file before first writting
},
},
},
lualine_x = {
{ place, padding = { left = 1, right = 1 } },
},
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {
"quickfix",
},
})
local lualine = require("lualine")
vim.api.nvim_create_autocmd("RecordingEnter", {
callback = function()
lualine.refresh()
end,
})
vim.api.nvim_create_autocmd("RecordingLeave", {
callback = function()
-- This is going to seem really weird!
-- Instead of just calling refresh we need to wait a moment because of the nature of
-- `vim.fn.reg_recording`. If we tell lualine to refresh right now it actually will
-- still show a recording occuring because `vim.fn.reg_recording` hasn't emptied yet.
-- So what we need to do is wait a tiny amount of time (in this instance 50 ms) to
-- ensure `vim.fn.reg_recording` is purged before asking lualine to refresh.
local timer = vim.loop.new_timer()
timer:start(
50,
0,
vim.schedule_wrap(function()
lualine.refresh()
end)
)
end,
})
require("mini.ai").setup()
require("mini.bracketed").setup()
require("mini.bufremove").setup()
require("mini.indentscope").setup({
symbol = "",
draw = {
animation = require("mini.indentscope").gen_animation.none(),
},
})
require("mini.move").setup({
mappings = {
-- Move visual selection in Visual mode.
left = "<M-Left>",
right = "<M-Right>",
down = "<M-Down>",
up = "<M-Up>",
-- Move current line in Normal mode
line_left = "<M-Left>",
line_right = "<M-Right>",
line_down = "<M-Down>",
line_up = "<M-Up>",
},
})
local navbuddy = require("nvim-navbuddy")
local actions = require("nvim-navbuddy.actions")
navbuddy.setup({
window = {
border = "double",
},
mappings = {
["<Down>"] = actions.next_sibling(), -- down
["<Up>"] = actions.previous_sibling(), -- up
["<Left>"] = actions.parent(), -- Move to left panel
["<Right>"] = actions.children(), -- Move to right panel
["<PageDown>"] = actions.root(), -- Move to first panel
},
lsp = {
auto_attach = true,
},
})
require("pounce").setup({
accept_keys = "NTESIROAGJKDFVBYMCXWPQZ",
accept_best_key = "<enter>",
multi_window = true,
debug = false,
})
require("range-highlight").setup({})
require("session-lens").setup({
prompt_title = "Session Switcher",
})
-- Use spelling for markdown files ‘]s’ to find next, ‘[s’ for previous, 'z=‘ for suggestions when on one.
vim.api.nvim_create_autocmd("FileType", {
pattern = { "html", "markdown", "text" },
callback = function()
vim.opt_local.spell = true
end,
})
-- Telescope Global remapping
local action_state = require("telescope.actions.state")
local actions = require("telescope.actions")
local fb_actions = require("telescope._extensions.file_browser.actions")
--- Insert filename into the current buffer and keeping the insert mode.
actions.insert_name_i = function(prompt_bufnr)
local symbol = action_state.get_selected_entry().ordinal
actions.close(prompt_bufnr)
vim.schedule(function()
vim.cmd([[startinsert]])
vim.api.nvim_put({ symbol }, "", true, true)
end)
end
--- Insert file path and name into the current buffer and keeping the insert mode.
actions.insert_name_and_path_i = function(prompt_bufnr)
local symbol = action_state.get_selected_entry().value
actions.close(prompt_bufnr)
vim.schedule(function()
vim.cmd([[startinsert]])
vim.api.nvim_put({ symbol }, "", true, true)
end)
end
require("telescope").setup({
defaults = {
sorting_strategy = "descending",
prompt_prefix = "",
winblend = 25,
mappings = {
i = {
["<esc>"] = actions.close,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
},
},
},
extensions = {
file_browser = {
theme = "ivy",
hidden = true,
path = "%:p:h",
mappings = {
["i"] = {
["<S-M>"] = fb_actions.move,
["<C-G>"] = fb_actions.goto_parent_dir,
["<C-Y>"] = actions.insert_name_i,
["<C-P>"] = actions.insert_name_and_path_i,
},
},
},
},
pickers = {
find_files = {
theme = "ivy",
find_command = { "rg", "--files", "--hidden", "-g", "!.git" },
},
live_grep = {
theme = "ivy",
},
buffers = {
theme = "ivy",
sort_mru = true,
ignore_current_buffer = true,
mappings = {
i = {
["<C-w>"] = "delete_buffer",
},
n = {
["<C-w>"] = "delete_buffer",
},
},
},
},
})
require("telescope").load_extension("fzf")
require("telescope").load_extension("file_browser")
require("nvim-treesitter.configs").setup({
rainbow = {
enable = true,
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
},
autotag = {
enable = true,
filetypes = {
"html",
"javascript",
"typescript",
"markdown",
},
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<CR>",
scope_incremental = "<CR>",
node_incremental = "<CR>",
node_decremental = "<TAB>",
},
},
})
-- Setup treesitter
local ts = require("nvim-treesitter.configs")
ts.setup({
ensure_installed = {
"c",
"css",
"scss",
"typescript",
"lua",
"html",
"javascript",
"json",
"php",
"rust",
"yaml",
"vim",
"toml",
},
highlight = { enable = true },
})
require("which-key").setup({
plugins = {
spelling = {
enabled = false,
},
},
})
require("zen-mode").setup({
window = {
width = 90,
options = {
number = false,
relativenumber = false,
signcolumn = "no",
cursorcolumn = false,
},
},
plugins = {
kitty = {
enabled = true,
font = "+2",
},
},
})
-- Dashboard
local dashboard = require("alpha.themes.dashboard")
math.randomseed(os.time())
local function button(sc, txt, keybind, keybind_opts)
local b = dashboard.button(sc, txt, keybind, keybind_opts)
b.opts.hl = "Function"
b.opts.hl_shortcut = "Type"
return b
end
local function pick_color()
local colors = { "String", "Identifier", "Keyword", "Number" }
return colors[math.random(#colors)]
end
local function footer()
local total_plugins = #vim.tbl_keys(packer_plugins)
local datetime = os.date(" %d-%m-%Y  %H:%M:%S")
return datetime
.. ""
.. total_plugins
.. " plugins"
.. "  v"
.. vim.version().major
.. "."
.. vim.version().minor
.. "."
.. vim.version().patch
end
dashboard.section.header.val = {
[[__/\\\\\\\\\\\\\____/\\\\\\\\\\\\\\\_ ]],
[[ _\/\\\/////////\\\_\/\\\///////////__ ]],
[[ _\/\\\_______\/\\\_\/\\\_____________ ]],
[[ _\/\\\\\\\\\\\\\\__\/\\\\\\\\\\\_____ ]],
[[ _\/\\\/////////\\\_\/\\\///////______ ]],
[[ _\/\\\_______\/\\\_\/\\\_____________ ]],
[[ _\/\\\_______\/\\\_\/\\\_____________ ]],
[[ _\/\\\\\\\\\\\\\/__\/\\\_____________]],
[[ _\/////////////____\///_____________]],
}
dashboard.section.header.opts.hl = pick_color()
dashboard.section.buttons.val = {
button("<Leader>e", " File Explorer"),
button("<Leader>p", " Find file"),
button("<Leader>f", " Find string"),
button("<Leader>xs", " Open session"),
button("<Leader>n", " New file"),
button("<Leader>v", " Config"),
button("<Leader>u", " Update plugins"),
button("q", " Quit", "<Cmd>qa<CR>"),
}
dashboard.section.footer.val = footer()
dashboard.section.footer.opts.hl = "Constant"
require("alpha").setup(dashboard.opts)
vim.g.catppuccin_flavour = "frappe" -- latte, frappe, macchiato, mocha
require("catppuccin").setup({
dim_inactive = {
enabled = true,
shade = "dark",
percentage = 0.15,
},
transparent_background = false,
term_colors = false,
compile = {
enabled = true,
path = vim.fn.stdpath("cache") .. "/catppuccin",
},
styles = {
comments = { "italic" },
conditionals = { "italic" },
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
},
integrations = {
treesitter = true,
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
},
},
coc_nvim = false,
lsp_trouble = false,
cmp = true,
lsp_saga = false,
gitgutter = false,
gitsigns = true,
leap = false,
pounce = true,
telescope = true,
nvimtree = {
enabled = false,
show_root = true,
transparent_panel = false,
},
neotree = {
enabled = false,
show_root = true,
transparent_panel = false,
},
dap = {
enabled = false,
enable_ui = false,
},
which_key = true,
indent_blankline = {
enabled = true,
colored_indent_levels = false,
},
dashboard = false,
neogit = false,
vim_sneak = false,
fern = false,
barbar = false,
bufferline = false,
markdown = true,
lightspeed = false,
ts_rainbow = false,
hop = false,
notify = true,
telekasten = false,
symbols_outline = true,
mini = false,
aerial = false,
vimwiki = false,
beacon = false,
},
color_overrides = {},
highlight_overrides = {},
custom_highlights = {
CursorLine = { bg = "#292c3c" },
CursorColumn = { bg = "#292c3c" },
},
})
vim.cmd([[colorscheme catppuccin]])
require("flash").setup({
labels = "ntesiroagjkdfvbymcxwpqz",
modes = {
search = {
enabled = false,
},
},
})
require("indent_blankline").setup({
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
use_treesitter = true,
use_treesitter_scope = true,
char = "",
context_char = "",
})
-- Nightfox config
local nightfox = require("nightfox")
nightfox.setup({
options = {
dim_inactive = true,
styles = {
comments = "italic",
keywords = "bold",
functions = "italic,bold",
},
inverse = {
search = true,
match_paren = true,
},
},
groups = {
all = {
CursorLine = { bg = "#353A54" },
CmpItemAbbr = { fg = "#9FA4B6" },
CmpItemKind = { fg = "#8289A0" },
CmpItemMenu = { fg = "#8289A0" },
PmenuSel = { bg = "#73daca", fg = "#111111" },
Pmenu = { bg = "#2E3248" },
GitSignsAddNr = { fg = "#26A07A" },
GitSignsDeleteNr = { fg = "#E87D7D" },
GitSignsChangeNr = { fg = "#AD991F" },
Visual = { fg = "#111111", bg = "#73daca" },
},
},
})
vim.cmd("colorscheme duskfox") -- Put your favorite colorscheme here
-- Here is the formatting config
local null_ls = require("null-ls")
local lSsources = {
null_ls.builtins.formatting.prettier.with({
filetypes = {
"javascript",
"typescript",
"css",
"scss",
"html",
"json",
"yaml",
"markdown",
"graphql",
"md",
"txt",
},
only_local = "node_modules/.bin",
}),
null_ls.builtins.formatting.stylua.with({
filetypes = {
"lua",
},
args = { "--indent-width", "2", "--indent-type", "Spaces", "-" },
}),
null_ls.builtins.diagnostics.stylelint.with({
filetypes = {
"css",
"scss",
},
}),
}
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
require("null-ls").setup({
sources = lSsources,
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
bufnr = bufnr,
filter = function(client)
return client.name == "null-ls"
end,
})
end,
})
end
end,
})
require("smoothcursor").setup({
fancy = {
enable = true,
},
})
@benfrain
Copy link
Author

benfrain commented Mar 1, 2022

Updated the mappings as had the Telescope mapping for diagnostics still set to the old style

@benfrain
Copy link
Author

Switched from Hop to Pounce: https://github.com/rlane/pounce.nvim and removed nvim-tree (wasn't using it, use telescope file browser for that use case)

@benfrain
Copy link
Author

benfrain commented Apr 4, 2022

Added a command to the options.lua from https://www.reddit.com/r/neovim/comments/f0qx2y/comment/fgxa0f8/ to try and deal with git updates better

@benfrain
Copy link
Author

Updates for Neovim 0.7
Also added some augroups to make the cursor lines only appear on the focused windows in a split

@benfrain
Copy link
Author

added friendly snippets as a requirement of cmp, for easy boilerplate of HTML etc

@benfrain
Copy link
Author

benfrain commented May 3, 2022

Updated to use latest Tree Sitter setup with individually specified languages. If you want all available languages, set it to 'all' instead:

require("nvim-treesitter.configs").setup({
  rainbow = {
    enable = true,
    extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
    max_file_lines = nil, -- Do not enable for files with more than n lines, int
  },
  autotag = {
    enable = true,
    filetypes = {
      "html",
      "javascript",
      "typescript",
      "markdown",
    },
  },
  incremental_selection = {
    enable = true,
    keymaps = {
      init_selection = "<CR>",
      scope_incremental = "<CR>",
      node_incremental = "<CR>",
      node_decremental = "<TAB>",
    },
  },
})
-- Setup treesitter
local ts = require("nvim-treesitter.configs")
ts.setup({
  ensure_installed = {
    "all",
  },
  highlight = { enable = true },
})

@benfrain
Copy link
Author

benfrain commented May 3, 2022

Adding mapping into cmp config so when autocompleting on the cmd mode i can press ESC and exit autocomplete but keep typing

@benfrain
Copy link
Author

benfrain commented May 5, 2022

Undoing the change with ESC in cmp as it meant I needed to press ESC twice in insert mode everytime I want

@the-mrd
Copy link

the-mrd commented May 6, 2022

Shouldn't the packer compile autocmd reference plugins.lua instead of init.lua ?

vim.api.nvim_create_autocmd(
  "BufWritePost",
  { command = "source <afile> | PackerCompile", group = packer_group, pattern = "init.lua" }
)

We want the compile command to trigger when changing something related to the plugins, no?

@benfrain
Copy link
Author

benfrain commented May 6, 2022

Shouldn't the packer compile autocmd reference plugins.lua instead of init.lua ?

vim.api.nvim_create_autocmd(
  "BufWritePost",
  { command = "source <afile> | PackerCompile", group = packer_group, pattern = "init.lua" }
)

We want the compile command to trigger when changing something related to the plugins, no?

Yes! Thanks, I’ll update.

@benfrain
Copy link
Author

Updated Nightfox config so overrides actually work!

@benfrain
Copy link
Author

updated cmp to provide completions from all visible buffers.

@benfrain
Copy link
Author

Switched out separate renamer plugin for dressing.

@the-mrd
Copy link

the-mrd commented May 18, 2022

Is nvim-colorizer still useful/used with nightfox? Don't they conflict or override?

@benfrain
Copy link
Author

benfrain commented May 19, 2022

Is nvim-colorizer still useful/used with nightfox? Don't they conflict or override?

They serve different purposes. colorizer just changes text/hex values in the code you are editing into the appropriate color background. night fox is the color theme.

@benfrain
Copy link
Author

LSP/null-ls updates to deal with neovim 0.8

@benfrain
Copy link
Author

benfrain commented Jul 7, 2022

made Ivy the default picker layout for all the Telescope pickers

@benfrain
Copy link
Author

benfrain commented Jul 13, 2022

swapped the surround plugin put it back to original tpope surround as new one seems flakey

@benfrain
Copy link
Author

Changed Telescope buffers so it shows Most Recently Used and ignores the current buffer from the list

@benfrain
Copy link
Author

Added indent blank line and used options so it only shows on active buffer

@benfrain
Copy link
Author

Noticed that the mapping map("n", "n", "nzz"), which I was using to move to the next search result but center it, was actually stopping the built it search result from displaying and updating. Removed those and similar mappings and removed some other mappings I never actually use like tab to move to next buffer.

@benfrain
Copy link
Author

benfrain commented Oct 7, 2022

Removed a few plugins I rarely use. removed stabilize as it is in Nightly core now as splitkeep option: https://www.reddit.com/r/neovim/comments/xx3fom/new_option_splitkeep_merged_into_master/

@benfrain
Copy link
Author

benfrain commented Nov 8, 2022

Added descriptions to mappings, added Which Key

@benfrain
Copy link
Author

Swapped to Lazy based config

@benfrain
Copy link
Author

Added mini.move for line bubbling and removed the existing mappings I had from mappings.lua

@benfrain
Copy link
Author

Added an LSP hover shortcut and a function to remove any popups when Esc is pressed.

@benfrain
Copy link
Author

Lualine has its own searchcount component now, so removed my own from Lualine config

@benfrain
Copy link
Author

benfrain commented Feb 2, 2023

Added comment box plugin and mappings, removed headlines plugin

@benfrain
Copy link
Author

Amended the LSP and mappings so that I only see diagnostic messages on a line with my mapping. Still get the gutter icon at all times.

@benfrain
Copy link
Author

Removing these:

treesitter-textobjects can go.
nvim-autopairs
num2str comment
kylechui surround
welle targets
famiu/bufdelete.nvim
indentblankline

And replacing with these:

mini.ai
mini.pairs
mini.surround
mini.comment
mini.move
mini.bracketed
mini.bufremove
mini.indentscope

@benfrain
Copy link
Author

benfrain commented Mar 6, 2023

Updated the Kanagawa config to deal with breaking changes there

@benfrain
Copy link
Author

Gone back to Kylechui for surround; prefer it.

@benfrain
Copy link
Author

Gone back to nvim-autopairs over mini.pairs; think it works better

@benfrain
Copy link
Author

Updated auto-session config and lualine usage

@benfrain
Copy link
Author

Adding navbuddy

@benfrain
Copy link
Author

removed null-ls/pounce, trying conform and flash

@benfrain
Copy link
Author

switching out mini.comment as it seemed to constantly fail with block comments in scss/ts files.

@benfrain
Copy link
Author

Currently unused plugin configs now prefixed with 'x-' so they are at the bottom

@benfrain
Copy link
Author

Going back to Pounce, find Flash does too much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment