Lua init file for NeoVim 0.7+ (Always a WIP!!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- note only needed when working with zmk. goes in the config root. | |
vim.filetype.add({ | |
extension = { | |
keymap = "dts", | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- You will need to install language servers `npm i -g vscode-langservers-extracted` and `npm install -g typescript typescript-language-server` | |
require("plugins") | |
require("options") | |
require("setup.spelling") | |
require("mappings") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function map(mode, lhs, rhs, opts) | |
local options = { noremap = true } | |
if opts then | |
options = vim.tbl_extend("force", options, opts) | |
end | |
vim.api.nvim_set_keymap(mode, lhs, rhs, options) | |
end | |
-- Map leader to space | |
vim.g.mapleader = "," | |
-- Nvim Tree | |
map("n", "<leader>e", ":NvimTreeToggle<CR>", { silent = true }) | |
map("n", "<leader>u", ":NvimTreeFindFile<CR>", { silent = true }) | |
-- Switch Session | |
-- map("n", "<Leader>1", ":Telescope sessions [save_current=true]<CR>") | |
map("n", "<Leader>1", ":SearchSession<CR>") | |
-- Update Plugins | |
map("n", "<Leader>u", ":PackerSync<CR>") | |
-- Open nvimrc file | |
map("n", "<Leader>v", "<cmd>e $MYVIMRC<CR>") | |
-- Source nvimrc file | |
map("n", "<Leader>sv", ":luafile %<CR>") | |
-- Quick new file | |
map("n", "<Leader>n", "<cmd>enew<CR>") | |
-- Easy select all of file | |
map("n", "<Leader>sa", "ggVG<c-$>") | |
-- Make visual yanks place the cursor back where started | |
map("v", "y", "ygv<Esc>") | |
-- Easier file save | |
map("n", "<Leader>w", "<cmd>:w<CR>") | |
map("n", "<Delete>", "<cmd>:w<CR>") | |
-- Tab to switch buffers in Normal mode | |
map("n", "<Tab>", ":bnext<CR>") | |
map("n", "<S-Tab>", ":bprevious<CR>") | |
-- More molecular undo of text | |
-- map("i", ",", ",<c-g>u") | |
map("i", ".", ".<c-g>u") | |
map("i", "!", "!<c-g>u") | |
map("i", "?", "?<c-g>u") | |
map("i", ";", ";<c-g>u") | |
map("i", ":", ":<c-g>u") | |
-- Keep search results centred | |
map("n", "n", "nzzzv") | |
map("n", "N", "Nzzzv") | |
map("n", "J", "mzJ`z") | |
-- Make Y yank to end of the line | |
map("n", "Y", "y$") | |
-- Line bubbling | |
map("n", "<c-j>", "<cmd>m .+1<CR>==", { silent = true }) | |
map("n", "<c-k>", "<cmd>m .-2<CR>==", { silent = true }) | |
map("v", "<c-j>", ":m '>+1<CR>==gv=gv", { silent = true }) | |
map("v", "<c-k>", ":m '<-2<CR>==gv=gv", { silent = true }) | |
--After searching, pressing escape stops the highlight | |
map("n", "<esc>", ":noh<cr><esc>", { silent = true }) | |
-- Easy add date/time | |
map("n", "<Leader>t", "\"=strftime('%c')<CR>Pa", { silent = true }) | |
-- Telescope | |
local km = vim.keymap | |
-- Add moves of more than 5 to the jump list | |
km.set("n", "j", [[(v:count > 5 ? "m'" . v:count : "") . 'j']], { expr = true, desc = "if j > 5 then add to jumplist" }) | |
km.set("n", "<leader>p", function() | |
require("telescope.builtin").find_files() | |
end) | |
km.set("n", "<leader>r", function() | |
require("telescope.builtin").registers() | |
end) | |
km.set("n", "<leader>g", function() | |
require("telescope.builtin").live_grep() | |
end) | |
km.set("n", "<leader>b", function() | |
require("telescope.builtin").buffers() | |
end) | |
km.set("n", "<leader>j", function() | |
require("telescope.builtin").help_tags() | |
end) | |
km.set("n", "<leader>h", function() | |
require("telescope.builtin").git_bcommits() | |
end) | |
km.set("n", "<leader>f", function() | |
require("telescope").extensions.file_browser.file_browser() | |
end) | |
km.set("n", "<leader>s", function() | |
require("telescope.builtin").spell_suggest(require("telescope.themes").get_cursor({})) | |
end) | |
km.set("n", "<leader>i", function() | |
require("telescope.builtin").git_status() | |
end) | |
km.set("n", "<leader>ca", function() | |
vim.lsp.buf.code_action() | |
end) | |
km.set("n", "<leader>cs", function() | |
require("telescope.builtin").lsp_document_symbols() | |
end) | |
km.set("n", "<leader>cd", function() | |
require("telescope.builtin").diagnostics() | |
end) | |
km.set("n", "<leader>cr", function() | |
require("telescope.builtin").lsp_references() | |
end) | |
km.set({ "v", "n" }, "<leader>cn", function() | |
vim.lsp.buf.rename() | |
end, { noremap = true, silent = true }) | |
km.set("n", "<leader>ci", function() | |
vim.diagnostic.open_float() | |
end) | |
-- Easier split mappings | |
map("n", "<Leader><Down>", "<C-W><C-J>", { silent = true }) | |
map("n", "<Leader><Up>", "<C-W><C-K>", { silent = true }) | |
map("n", "<Leader><Right>", "<C-W><C-L>", { silent = true }) | |
map("n", "<Leader><Left>", "<C-W><C-H>", { silent = true }) | |
map("n", "<Leader>;", "<C-W>R", { silent = true }) | |
map("n", "<Leader>[", "<C-W>_", { silent = true }) | |
map("n", "<Leader>]", "<C-W>|", { silent = true }) | |
map("n", "<Leader>=", "<C-W>=", { silent = true }) | |
-- Pounce | |
km.set({ "n", "v" }, "h", ":Pounce<CR>", { silent = true }) | |
km.set("n", "H", ":PounceRepeat<CR>", { silent = true }) | |
-- Symbols outline | |
map("n", "<leader>o", ":SymbolsOutline<cr>") | |
-- ZenMode toggle | |
map("n", "<leader>z", ":ZenMode<cr>") | |
-- Make Option and backspace delete whole words in OSX/Kitty. Requires `macos_option_as_alt yes` to be set in Kitty config | |
map("i", "<A-BS>", "<C-W>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.expandtab = true -- Use spaces instead of tabs | |
opt.foldenable = false | |
opt.foldmethod = "indent" | |
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.list = true -- Show some invisible characters | |
opt.listchars = { tab = " ", trail = "·" } | |
opt.relativenumber = true | |
opt.scrolloff = 4 -- Lines of context | |
opt.shiftround = true -- Round indent | |
opt.shiftwidth = 4 -- Size of an indent | |
opt.showmode = false -- Don't display mode | |
opt.sidescrolloff = 8 -- Columns of context | |
opt.signcolumn = "yes:1" -- always show signcolumns | |
opt.smartcase = true -- Do not ignore case with capitals | |
opt.smartindent = true -- Insert indents automatically | |
opt.spelllang = { "en_gb" } | |
opt.splitbelow = true -- Put new windows below current | |
opt.splitright = true -- Put new windows right of current | |
opt.tabstop = 4 -- Number of spaces tabs count for | |
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' | |
vim.g.do_filetype_lua = 1 -- new filetype detection | |
vim.g.did_load_filetypes = 0 | |
-- 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-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") | |
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 } | |
) | |
-- Deal with file loads after updating via git etc | |
opt.autoread = true | |
-- -- trigger `autoread` when files changes on disk | |
-- vim.cmd([[ | |
-- autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif | |
-- autocmd FileChangedShellPost * | |
-- \ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None | |
-- ]]) | |
-- 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 = { "*" }, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local packer_group = vim.api.nvim_create_augroup("Packer", { clear = true }) | |
vim.api.nvim_create_autocmd( | |
"BufWritePost", | |
{ command = "source <afile> | PackerCompile", group = packer_group, pattern = "plugins.lua" } | |
) | |
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 | |
packer_bootstrap = fn.system({ | |
"git", | |
"clone", | |
"--depth", | |
"1", | |
"https://github.com/wbthomason/packer.nvim", | |
install_path, | |
}) | |
end | |
vim.api.nvim_command("packadd packer.nvim") | |
-- returns the require for use in `config` parameter of packer's use | |
-- expects the name of the config file | |
function get_setup(name) | |
return string.format('require("setup/%s")', name) | |
end | |
return require("packer").startup({ | |
function(use) | |
-- Packer can manage itself | |
use({ "wbthomason/packer.nvim" }) | |
use({ "EdenEast/nightfox.nvim", config = get_setup("nightfox") }) | |
use({ "kyazdani42/nvim-web-devicons" }) | |
use({ | |
"nvim-lualine/lualine.nvim", | |
config = get_setup("lualine"), | |
event = "VimEnter", | |
requires = { "kyazdani42/nvim-web-devicons", opt = true }, | |
}) | |
use({ | |
"folke/zen-mode.nvim", | |
config = get_setup("zen-mode"), | |
}) | |
use({ | |
"norcalli/nvim-colorizer.lua", | |
event = "BufReadPre", | |
config = get_setup("colorizer"), | |
}) | |
use({ | |
"nvim-treesitter/nvim-treesitter", | |
config = get_setup("treesitter"), | |
run = ":TSUpdate", | |
}) | |
use({ "nvim-treesitter/nvim-treesitter-textobjects" }) | |
use({ "nvim-treesitter/nvim-treesitter-context" }) | |
use({ "rcarriga/nvim-notify" }) | |
use({ | |
"windwp/nvim-autopairs", | |
after = "nvim-cmp", | |
config = get_setup("autopairs"), | |
}) | |
use({ | |
"hrsh7th/nvim-cmp", | |
requires = { | |
{ "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" }, | |
{ "rafamadriz/friendly-snippets" }, | |
}, | |
config = get_setup("cmp"), | |
}) | |
use({ | |
"numToStr/Comment.nvim", | |
config = function() | |
require("Comment").setup() | |
end, | |
}) | |
use({ | |
"rlane/pounce.nvim", | |
config = get_setup("pounce"), | |
}) | |
use({ | |
"lewis6991/gitsigns.nvim", | |
requires = { "nvim-lua/plenary.nvim" }, | |
event = "BufReadPre", | |
config = get_setup("gitsigns"), | |
}) | |
use({ "p00f/nvim-ts-rainbow" }) | |
use({ "jose-elias-alvarez/null-ls.nvim", config = get_setup("null-ls") }) | |
use({ "neovim/nvim-lspconfig", config = get_setup("lsp") }) | |
use({ | |
"nvim-telescope/telescope.nvim", | |
module = "telescope", | |
cmd = "Telescope", | |
requires = { | |
{ "nvim-lua/plenary.nvim" }, | |
{ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, | |
}, | |
config = get_setup("telescope"), | |
}) | |
use({ "nvim-telescope/telescope-file-browser.nvim" }) | |
use({ "onsails/lspkind-nvim", requires = { { "famiu/bufdelete.nvim" } } }) | |
use({ "tpope/vim-repeat" }) | |
use({ "tpope/vim-surround" }) | |
use({ "wellle/targets.vim" }) | |
use({ | |
"rmagatti/session-lens", | |
requires = { "rmagatti/auto-session", "nvim-telescope/telescope.nvim" }, | |
config = get_setup("session"), | |
}) | |
use({ "windwp/nvim-ts-autotag" }) | |
use({ | |
"winston0410/range-highlight.nvim", | |
requires = { { "winston0410/cmd-parser.nvim" } }, | |
config = get_setup("range-highlight"), | |
}) | |
use({ "goolord/alpha-nvim", config = get_setup("alpha") }) | |
use({ "luukvbaal/stabilize.nvim", config = get_setup("stabilize") }) | |
use({ | |
"simrat39/symbols-outline.nvim", | |
cmd = { "SymbolsOutline" }, | |
setup = get_setup("outline"), | |
}) | |
if packer_bootstrap then | |
require("packer").sync() | |
end | |
end, | |
config = { | |
display = { | |
open_fn = require("packer.util").float, | |
}, | |
profile = { | |
enable = true, | |
threshold = 1, -- the amount in ms that a plugins load time must be over for it to be included in the profile | |
}, | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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>f", " File Explorer"), | |
button("<Leader>p", " Find file"), | |
button("<Leader>g", " Find word"), | |
button("<Leader>1", " 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("nvim-autopairs").setup({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cmp = require("cmp") | |
local lspkind = require("lspkind") | |
cmp.setup({ | |
snippet = { | |
expand = function(args) | |
-- For `vsnip` user. | |
vim.fn["vsnip#anonymous"](args.body) | |
end, | |
}, | |
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" } | |
), | |
}, | |
completion = { | |
completeopt = "menu,menuone,noinsert", | |
keyword_length = 2, | |
}, | |
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 = { | |
format = lspkind.cmp_format({ | |
with_text = true, | |
maxwidth = 50, | |
menu = { | |
buffer = "", | |
nvim_lsp = "", | |
spell = "", | |
look = "", | |
}, | |
}), | |
}, | |
experimental = { | |
ghost_text = true, | |
native_menu = false, | |
}, | |
}) | |
-- cmp.setup.cmdline("/", { | |
-- mapping = cmp.mapping.preset.cmdline(), | |
-- sources = { | |
-- { name = "buffer" }, | |
-- }, | |
-- }) | |
cmp.setup.cmdline(":", { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = cmp.config.sources({ | |
{ name = "path" }, | |
}), | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("colorizer").setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("Comment").setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- gitsigns setup | |
require("gitsigns").setup({ | |
numhl = true, | |
signcolumn = false, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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", | |
}, | |
} | |
-- Different machine VAR for office | |
local envMachine = os.getenv("MACHINE") | |
if envMachine == "work" then | |
machineCmd = | |
"/System/Volumes/Data/usr/local/lib/node_modules/vscode-langservers-extracted/bin/vscode-css-language-server" | |
else | |
machineCmd = "vscode-css-language-server" | |
end | |
-- LSP Server config | |
require("lspconfig").cssls.setup({ | |
cmd = { machineCmd, "--stdio" }, | |
settings = { | |
scss = { | |
lint = { | |
idSelector = "warning", | |
zeroUnits = "warning", | |
duplicateProperties = "warning", | |
}, | |
completion = { | |
completePropertyWithSemicolon = true, | |
triggerPropertyValueCompletion = true, | |
}, | |
}, | |
}, | |
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()), | |
on_attach = function(client) | |
client.server_capabilities.document_formatting = false | |
end, | |
}) | |
require("lspconfig").tsserver.setup({ | |
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()), | |
on_attach = function(client) | |
client.server_capabilities.document_formatting = false | |
end, | |
}) | |
require("lspconfig").html.setup({ | |
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()), | |
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 | |
vim.cmd([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float()]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 lineNum = vim.api.nvim_win_get_cursor(0)[1] | |
local function getLines() | |
return tostring(vim.api.nvim_win_get_cursor(0)[1]) .. "/" .. tostring(vim.api.nvim_buf_line_count(0)) | |
end | |
local function getColumn() | |
local val = vim.api.nvim_win_get_cursor(0)[2] | |
-- pad value to 3 units to stop geometry shift | |
return string.format("%03d", val) | |
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 | |
-- get colors from Nightfox to use in the words count | |
-- local nfColors = require("nightfox.colors").init("nordfox") | |
-- 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 = function(res) | |
return res:sub(1, 1) | |
end, | |
} }, | |
lualine_b = { | |
{ "branch", icon = "" }, | |
{ "diff", source = diff_source, color_added = "#a7c080", color_modified = "#ffdf1b", color_removed = "#ff6666" }, | |
}, | |
lualine_c = { | |
{ "diagnostics", sources = { "nvim_diagnostic" } }, | |
function() | |
return "%=" | |
end, | |
{ "filename", path = 1, shorting_target = 40 }, | |
{ | |
getWords, | |
-- color = { fg = nfColors["bg_alt"] or "#333333", bg = nfColors["fg"] or "#eeeeee" }, | |
color = { fg = "#333333", bg = "#eeeeee" }, | |
separator = { left = "", right = "" }, | |
}, | |
}, | |
lualine_x = { { "filetype", icon_only = true } }, | |
lualine_y = { { require("auto-session-library").current_session_name } }, | |
lualine_z = { | |
{ getColumn, padding = { left = 1, right = 0 } }, | |
{ getLines, icon = "", padding = 1 }, | |
}, | |
}, | |
inactive_sections = { | |
lualine_a = {}, | |
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 }, | |
}, | |
lualine_x = { { getLines, icon = "", padding = 1 } }, | |
lualine_y = {}, | |
lualine_z = {}, | |
}, | |
tabline = {}, | |
extensions = { | |
"quickfix", | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Here is the formatting config | |
local null_ls = require("null-ls") | |
local lSsources = { | |
null_ls.builtins.formatting.prettierd.with({ | |
filetypes = { | |
"javascript", | |
"typescript", | |
"css", | |
"scss", | |
"html", | |
"json", | |
"yaml", | |
"markdown", | |
"graphql", | |
"md", | |
"txt", | |
}, | |
}), | |
null_ls.builtins.formatting.stylua.with({ | |
filetypes = { | |
"lua", | |
}, | |
args = { "--indent-width", "2", "--indent-type", "Spaces", "-" }, | |
}), | |
} | |
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.formatting_seq_sync() | |
end, | |
}) | |
end | |
end, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.g.symbols_outline = { | |
highlight_hovered_item = true, | |
show_guides = true, | |
auto_preview = false, | |
width = 50, | |
position = "right", | |
show_numbers = false, | |
show_relative_numbers = false, | |
show_symbol_details = true, | |
keymaps = { | |
close = "<Esc>", | |
goto_location = "<Cr>", | |
focus_location = "o", | |
hover_symbol = "<C-space>", | |
rename_symbol = "r", | |
code_actions = "a", | |
}, | |
lsp_blacklist = { "null-ls" }, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("pounce").setup({ | |
accept_keys = "NTESIROAGJKDFVBYMCXWPQZ", | |
accept_best_key = "<enter>", | |
multi_window = true, | |
debug = false, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("range-highlight").setup({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("renamer").setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("session-lens").setup({ | |
prompt_title = "Session Switcher", | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Use spelling for markdown files ‘]s’ to find next, ‘[s’ for previous, 'z=‘ for suggestions when on one. | |
-- Source: http:--thejakeharding.com/tutorial/2012/06/13/using-spell-check-in-vim.html | |
vim.api.nvim_exec( | |
[[ | |
augroup markdownSpell | |
autocmd! | |
autocmd FileType markdown,md,txt setlocal spell | |
autocmd BufRead,BufNewFile *.md,*.txt,*.markdown setlocal spell | |
augroup END | |
]], | |
false | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("stabilize").setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Telescope Global remapping | |
local action_state = require("telescope.actions.state") | |
local actions = require("telescope.actions") | |
local fb_actions = require("telescope._extensions.file_browser.actions") | |
require("telescope").setup({ | |
defaults = { | |
winblend = 20, | |
sorting_strategy = "descending", | |
layout_strategy = "flex", | |
prompt_prefix = " ", | |
layout_config = { | |
flex = { | |
flip_columns = 140, | |
}, | |
vertical = { | |
prompt_position = "bottom", | |
}, | |
horizontal = { | |
width = 0.9, | |
height = 0.8, | |
}, | |
}, | |
mappings = { | |
i = { | |
["<esc>"] = actions.close, | |
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, | |
}, | |
}, | |
}, | |
extensions = { | |
file_browser = { | |
theme = "ivy", | |
mappings = { | |
["i"] = { | |
["<S-M>"] = fb_actions.move, | |
}, | |
["n"] = { | |
-- your custom normal mode mappings | |
}, | |
}, | |
}, | |
}, | |
pickers = { | |
buffers = { | |
sort_lastused = true, | |
mappings = { | |
i = { | |
["<C-w>"] = "delete_buffer", | |
}, | |
n = { | |
["<C-w>"] = "delete_buffer", | |
}, | |
}, | |
}, | |
-- https://gitter.im/nvim-telescope/community?at=6113b874025d436054c468e6 Fabian David Schmidt | |
find_files = { | |
on_input_filter_cb = function(prompt) | |
local find_colon = string.find(prompt, ":") | |
if find_colon then | |
local ret = string.sub(prompt, 1, find_colon - 1) | |
vim.schedule(function() | |
local prompt_bufnr = vim.api.nvim_get_current_buf() | |
local picker = action_state.get_current_picker(prompt_bufnr) | |
local lnum = tonumber(prompt:sub(find_colon + 1)) | |
if type(lnum) == "number" then | |
local win = picker.previewer.state.winid | |
local bufnr = picker.previewer.state.bufnr | |
local line_count = vim.api.nvim_buf_line_count(bufnr) | |
vim.api.nvim_win_set_cursor(win, { math.max(1, math.min(lnum, line_count)), 0 }) | |
end | |
end) | |
return { prompt = ret } | |
end | |
end, | |
attach_mappings = function() | |
actions.select_default:enhance({ | |
post = function() | |
-- if we found something, go to line | |
local prompt = action_state.get_current_line() | |
local find_colon = string.find(prompt, ":") | |
if find_colon then | |
local lnum = tonumber(prompt:sub(find_colon + 1)) | |
vim.api.nvim_win_set_cursor(0, { lnum, 0 }) | |
end | |
end, | |
}) | |
return true | |
end, | |
}, | |
}, | |
}) | |
require("telescope").load_extension("fzf") | |
require("telescope").load_extension("session-lens") | |
require("telescope").load_extension("file_browser") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("zen-mode").setup({ | |
window = { | |
width = 90, | |
options = { | |
number = false, | |
relativenumber = false, | |
signcolumn = "no", | |
cursorcolumn = false, | |
}, | |
}, | |
plugins = { | |
kitty = { | |
enabled = true, | |
font = "+2", | |
}, | |
}, | |
}) |
Switched out separate renamer plugin for dressing.
Is nvim-colorizer
still useful/used with nightfox? Don't they conflict or override?
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.
LSP/null-ls updates to deal with neovim 0.8
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated cmp to provide completions from all visible buffers.