Merge branch 'main' of github.com:jim-fx/.dotfiles

This commit is contained in:
max_richter 2022-01-04 15:45:50 +01:00
commit d254ac027e
17 changed files with 240 additions and 751 deletions

View File

@ -56,6 +56,10 @@ if [ -d "$HOME/.asdf" ] ; then
. "$HOME/.asdf/asdf.sh" . "$HOME/.asdf/asdf.sh"
fi fi
if [ "$(which go)" != "" ] ; then
export PATH="$PATH:$(go env GOPATH)/bin"
fi
#If fdfind is installed force fzf to use it #If fdfind is installed force fzf to use it
if type fdfind &> /dev/null ; then if type fdfind &> /dev/null ; then
export FZF_DEFAULT_COMMAND='fdfind --type f' export FZF_DEFAULT_COMMAND='fdfind --type f'

View File

@ -7,209 +7,214 @@ local g = vim.g
local cmd = vim.cmd local cmd = vim.cmd
local opt = vim.opt local opt = vim.opt
require ("plugins") require("plugins")
if u.has_plugin("cmp") then if u.has_plugin("cmp") then
vim.g.did_load_filetypes = 150
vim.g.did_load_filetypes = 1 -- Global options
o.number = true -- show line number
o.showmatch = true -- show matching brackets
-- Global options -- Indentation options
o.number = true -- show line number vim.cmd [[
o.showmatch = true -- show matching brackets set autoindent
o.swapfile = false set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=1
]]
-- Indentation options g.hidden = true -- unload buffers when hidden
vim.cmd [[ g.filetype = true -- execute autocommands based on filetype
set autoindent o.autoread = true
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
]]
g.hidden = true --unload buffers when hidden -- Search
g.filetype = true -- execute autocommands based on filetype o.inccommand = "nosplit" -- show substitutions incrementally
o.autoread = true o.ignorecase = true
o.smartcase = true
opt.wildignore:append(".git/*", "node_modules/*")
o.wildignorecase = true
o.lazyredraw = true
-- Search opt.listchars:append(
o.inccommand = 'nosplit' -- show substitutions incrementally {
o.ignorecase = true extends = "#",
o.smartcase = true eol = "",
opt.wildignore:append('.git/*', 'node_modules/*') space = "",
o.wildignorecase = true tab = ""
o.lazyredraw = true }
)
opt.listchars:append({ -- Shortmess
extends = "#", cmd [[set shortmess+=F]]
eol = '', g.loaded_netrw = 1
space = '', g.loaded_netrwPlugin = 1
tab = '', g.loaded_zipPlugin = 1
}) g.loaded_zip = 1
-- Shortmess g.languagetool_server_jar = "~/build/languagetool/languagetool-server.jar"
cmd [[set shortmess+=F]] g.languagetool_lang = "de"
g.loaded_netrw = 1
g.loaded_netrwPlugin = 1
g.loaded_zipPlugin = 1
g.loaded_zip = 1
g.languagetool_server_jar = "~/build/languagetool/languagetool-server.jar" cmd [[set mouse=a]] -- enable mouse interaction
g.languagetool_lang= "de" cmd [[set undofile]]
cmd [[set fcs=eob:\ ]] -- disable showing ~ in empty lines
cmd [[set mouse=a]] -- enable mouse interaction cmd [[set noshowmode]] -- to get rid of thing like --INSERT--
cmd [[set undofile]] cmd [[set noshowcmd]] -- to get rid of display of last command
cmd [[set fcs=eob:\ ]] --disable showing ~ in empty lines cmd [[set shortmess+=F]] -- to get rid of the file name displayed in the command line bar
cmd [[command Format :lua vim.lsp.buf.formatting()]] cmd [[set noruler]]
cmd [[command FormatSync :lua vim.lsp.buf.formatting_sync()]]
cmd [[set noshowmode]] --to get rid of thing like --INSERT-- g.ale_fixers = {"prettier", "eslint"}
cmd [[set noshowcmd]] --to get rid of display of last command
cmd [[set shortmess+=F]] --to get rid of the file name displayed in the command line bar
cmd [[set noruler]] -- Enable Theming / Syntax
o.syntax = "enable"
o.termguicolors = true
cmd("colorscheme nightfox")
g.material_terminal_italics = 1
g.material_theme_style = "darker"
g.tokyonight_style = "night"
g.tokyonight_transparent_sidebar = true
require("nightfox").setup(
{
transparent = true
}
)
g.ale_fixers = {"prettier", "eslint"} require("transparent").setup({
-- Enable Theming / Syntax
o.syntax = "enable"
o.termguicolors = true
cmd("colorscheme tokyonight")
g.material_terminal_italics = 1
g.material_theme_style = "darker"
g.tokyonight_style = "night"
g.tokyonight_transparent_sidebar = true;
-- Remove background color
require("transparent").setup({enable = true})
cmd("highlight Normal guibg=none")
cmd("highlight NonText guibg=none")
require('neoscroll').setup()
-- Configure nvim-tree
g.nvim_tree_special_files = {}
g.nvim_tree_icons = {
default = "",
symlink = "",
git = {
unstaged = "*",
staged = "",
unmerged = "",
renamed = "",
untracked = "",
deleted = "",
ignored = ""
},
folder = {
arrow_open = ">",
arrow_closed = "<",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = ""
},
lsp = {
hint = "",
info = "",
warning = "",
error = ""
}
}
g.nvim_tree_highlight_opened_files = 1;
g.nvim_tree_group_empty = 1;
g.nvim_tree_indent_markers = 0;
g.nvim_tree_show_icons ={
folder_arrows = 0,
folders = 1,
files = 1,
git = 1
}
require("nvim-tree").setup {
auto_open = 1,
gitignore = 1,
group_empty = 1,
hijack_cursor = 1,
update_focused_file = {
enable = false,
},
diagnostics = {
enable = true, enable = true,
icons = { extra_groups = "All"
hint = "", })
info = "",
warning = "",
error = "",
},
},
view = {
auto_resize = true,
hide_root_folder = true,
winopts = {
signcolumn = "no"
}
}
}
require('nvim-tree.view').View.winopts.signcolumn = 'no'
-- Configure Wiki -- Remove background color
g.wiki_root = "~/Notes" cmd("highlight Normal guibg=none")
g.wiki_filetypes = {"md"} cmd("highlight NonText guibg=none")
g.wiki_link_extension = ".md"
-- KeyBindings require("formatter-conf")
require "keymappings"
require "nvim-tmux-navigation".setup { -- Configure nvim-tree
keybindings = { g.nvim_tree_special_files = {}
left = "<C-h>", g.nvim_tree_icons = {
down = "<C-j>", default = "",
up = "<C-k>", symlink = "",
right = "<C-l>", git = {
last_active = "<C-\\>", unstaged = "*",
next = "<C-Space>" staged = "",
} unmerged = "",
} renamed = "",
untracked = "",
require'nvim-autopairs'.setup() deleted = "",
ignored = ""
-- Treesitter config },
require "treesitter-conf" folder = {
arrow_open = ">",
-- Autocompletion Setup arrow_closed = "<",
require "snippets" default = "",
require "cmp-conf" open = "",
empty = "",
-- LSP Config empty_open = "",
require "lspinstaller-conf" symlink = "",
require "lazy-git" symlink_open = ""
},
require "autocommands" lsp = {
hint = "",
-- Setup rest.vim info = "",
require("rest-nvim").setup( warning = "",
{ error = ""
-- Open request results in a horizontal split }
result_split_horizontal = false,
-- Skip SSL verification, useful for unknown certificates
skip_ssl_verification = false,
-- Highlight request on run
highlight = {
enabled = true,
timeout = 150
},
-- Jump to request line on run
jump_to_request = false
} }
)
-- LSP Config g.nvim_tree_highlight_opened_files = 1
require "lspinstaller-conf" g.nvim_tree_group_empty = 1
require "lsp-conf" g.nvim_tree_indent_markers = 0
g.nvim_tree_show_icons = {
folder_arrows = 0,
folders = 1,
files = 1,
git = 1
}
require("nvim-tree").setup {
auto_open = 1,
gitignore = 1,
group_empty = 1,
hijack_cursor = 1,
update_focused_file = {
enable = false
},
diagnostics = {
enable = true,
icons = {
hint = "",
info = "",
warning = "",
error = ""
}
},
view = {
auto_resize = true,
hide_root_folder = true,
winopts = {
signcolumn = "no"
}
}
}
require("nvim-tree.view").View.winopts.signcolumn = "no"
-- Configure Wiki
g.wiki_root = "~/Notes"
g.wiki_filetypes = {"md"}
g.wiki_link_extension = ".md"
-- KeyBindings
require "keymappings"
require "nvim-tmux-navigation".setup {
keybindings = {
left = "<C-h>",
down = "<C-j>",
up = "<C-k>",
right = "<C-l>",
last_active = "<C-\\>",
next = "<C-Space>"
}
}
require "nvim-autopairs".setup()
-- Treesitter config
require "treesitter-conf"
-- Autocompletion Setup
require "snippets"
require "cmp-conf"
-- LSP Config
require "lspinstaller-conf"
require "lazy-git"
require "autocommands"
-- Setup rest.vim
require("rest-nvim").setup(
{
-- Open request results in a horizontal split
result_split_horizontal = false,
-- Skip SSL verification, useful for unknown certificates
skip_ssl_verification = false,
-- Highlight request on run
highlight = {
enabled = true,
timeout = 150
},
-- Jump to request line on run
jump_to_request = false
}
)
-- LSP Config
require "lspinstaller-conf"
require "lsp-conf"
else else
vim.cmd[[PackerSync]] vim.cmd [[PackerSync]]
end end

View File

@ -1,14 +1,10 @@
-- luasnip setup -- luasnip setup
local cmd = vim.cmd;
local luasnip = require "luasnip" local luasnip = require "luasnip"
local lspkind = require "lspkind" local lspkind = require "lspkind"
local cmp = require "cmp" local cmp = require "cmp"
local cmp_autopairs = require('nvim-autopairs.completion.cmp') local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local has_words_before = function()
local line, col = 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
cmp.setup { cmp.setup {
formatting = { formatting = {
format = lspkind.cmp_format({with_text = true, menu = ({ format = lspkind.cmp_format({with_text = true, menu = ({
@ -32,34 +28,27 @@ cmp.setup {
}, },
mapping = { mapping = {
['<C-Leader>'] = cmp.mapping.complete(), ['<C-Leader>'] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else else
fallback() fallback()
end end
end, { "i", "s" }), end,
["<S-Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
['<CR>'] = cmp.mapping.confirm({ ['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
}), }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}, },
sources = { sources = {
{name = "nvim-lua"},
{name = "nvim_lsp"}, {name = "nvim_lsp"},
{name = "luasnip"}, {name = "luasnip"},
{name = "path"}, {name = "path"},

View File

@ -1,8 +1,8 @@
local cmd = vim.cmd; local cmd = vim.cmd
cmd [[ cmd [[
augroup auto_format augroup auto_format
au! au!
au BufWritePre * FormatSync au BufWritePre * Neoformat
augroup END augroup END
]] ]]

View File

@ -34,13 +34,15 @@ map("n", "Y", "yy", options)
map("n", "<Leader>k", "{",options) map("n", "<Leader>k", "{",options)
map("n", "<Leader>j", "}",options) map("n", "<Leader>j", "}",options)
-- Move lines vscode style
map("n", "<A-j>", "<cmd>move +1<CR>", options) map("n", "<A-j>", "<cmd>move +1<CR>", options)
map("n", "<A-k>", "<cmd>move -2<CR>", options) map("n", "<A-k>", "<cmd>move -2<CR>", options)
map("i", "<A-j>", "<cmd>move +1<CR>", options) map("i", "<A-j>", "<cmd>move +1<CR>", options)
map("i", "<A-k>", "<cmd>move -2<CR>", options) map("i", "<A-k>", "<cmd>move -2<CR>", options)
map("v", "<A-j>", ":m '>+1<CR>gv=gv", options) map("v", "<A-j>", ":m '>+1<CR>gv=gv", options)
map("v", "<A-k>", ":m '<-2<CR>gv=gv", options) map("v", "<A-k>", ":m '<-2<CR>gv=gv", options)
map("n", "<A-S-k>", "YP", options);
map("n", "<A-S-j>", "Yp", options);
-- Faster git merge -- Faster git merge
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options) map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options)

View File

@ -13,7 +13,8 @@ return require("packer").startup(function()
use 'lervag/vimtex' use 'lervag/vimtex'
-- Theming Section -- Theming Section
use 'folke/tokyonight.nvim' -- use 'folke/tokyonight.nvim'
use 'EdenEast/nightfox.nvim'
use "xiyaowong/nvim-transparent" use "xiyaowong/nvim-transparent"
-- Layout Plugins -- Layout Plugins
@ -47,20 +48,16 @@ return require("packer").startup(function()
"folke/trouble.nvim", "folke/trouble.nvim",
requires = "kyazdani42/nvim-web-devicons", requires = "kyazdani42/nvim-web-devicons",
config = function() config = function()
require("trouble").setup { require("trouble").setup()
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
end end
} }
-- Syntax / Autocomplete -- Syntax / Autocomplete
use "terminalnode/sway-vim-syntax"
use "neovim/nvim-lspconfig" use "neovim/nvim-lspconfig"
use "github/copilot.vim" -- use "github/copilot.vim"
use "hrsh7th/nvim-cmp" use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-nvim-lsp" use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lua"
use "hrsh7th/cmp-path" use "hrsh7th/cmp-path"
use "hrsh7th/cmp-calc" use "hrsh7th/cmp-calc"
use "hrsh7th/cmp-buffer" use "hrsh7th/cmp-buffer"
@ -86,7 +83,7 @@ return require("packer").startup(function()
use "ellisonleao/glow.nvim" use "ellisonleao/glow.nvim"
-- Autoformat -- Autoformat
--use "sbdchd/neoformat" use "sbdchd/neoformat"
-- use "lukas-reineke/format.nvim" -- use "lukas-reineke/format.nvim"
-- General Popup Window -- General Popup Window

View File

@ -2,40 +2,42 @@ local M = {}
local cmd = vim.cmd local cmd = vim.cmd
function M.create_augroup(autocmds, name) function M.create_augroup(autocmds, name)
cmd('augroup ' .. name) cmd("augroup " .. name)
cmd('autocmd!') cmd("autocmd!")
for _, autocmd in ipairs(autocmds) do for _, autocmd in ipairs(autocmds) do
cmd('autocmd ' .. table.concat(autocmd, ' ')) cmd("autocmd " .. table.concat(autocmd, " "))
end end
cmd('augroup END') cmd("augroup END")
end end
function M.ReloadConfig() function M.ReloadConfig()
for name,_ in pairs(package.loaded) do for name, _ in pairs(package.loaded) do
if name:match('^cnull') then if name:match("^cnull") then
package.loaded[name] = nil package.loaded[name] = nil
end end
end end
dofile(vim.env.MYVIMRC) dofile(vim.env.MYVIMRC)
end end
local function dump(o) local function dump(o)
if type(o) == 'table' then if type(o) == "table" then
local s = '{ ' local s = "{ "
for k,v in pairs(o) do for k, v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end if type(k) ~= "number" then
s = s .. '['..k..'] = ' .. dump(v) .. ',' k = '"' .. k .. '"'
end end
return s .. '} ' s = s .. "[" .. k .. "] = " .. dump(v) .. ","
else end
return tostring(o) return s .. "} "
end else
end return tostring(o)
end
end
function M.has_plugin(pluginName) function M.has_plugin(pluginName)
local status = pcall(require, pluginName); local status = pcall(require, pluginName)
return status return status
end end
return M return M

21
node_modules/.modules.yaml generated vendored
View File

@ -1,21 +0,0 @@
hoistPattern:
- '*'
hoistedDependencies: {}
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 5
packageManager: pnpm@6.22.2
pendingBuilds: []
prunedAt: Wed, 17 Nov 2021 13:45:43 GMT
publicHoistPattern:
- '*types*'
- '*eslint*'
- '@prettier/plugin-*'
- '*prettier-plugin-*'
registries:
default: https://registry.npmjs.org/
skipped: []
storeDir: /home/jim/.pnpm-store/v3
virtualStoreDir: .pnpm

15
node_modules/.pnpm/lock.yaml generated vendored
View File

@ -1,15 +0,0 @@
lockfileVersion: 5.3
specifiers:
vite-plugin-fonts: ^0.2.2
devDependencies:
vite-plugin-fonts: 0.2.2
packages:
/vite-plugin-fonts/0.2.2:
resolution: {integrity: sha512-fhzhsrTiuzlDjSO6g5sV5EVIIvbb8lmsaIY6eUTBM4lcF55x40UBpHrcyvNwIhQG211g0lu83XC7oZlkmvdkMA==}
peerDependencies:
vite: ^2.0.0
dev: true

View File

@ -1,113 +0,0 @@
# vite-plugin-fonts
Webfont loader for vite
### Install
```sh
npm i --save-dev vite-plugin-fonts # yarn add -D vite-plugin-fonts
```
### Add it to vite.config.js
```ts
// vite.config.js
import ViteFonts from 'vite-plugin-fonts'
export default {
plugins: [
ViteFonts({
google: {
families: ['Source Sans Pro']
},
})
],
}
```
## Options
```ts
// vite.config.js
import ViteFonts from 'vite-plugin-fonts'
export default {
plugins: [
ViteFonts({
// Typekit API
typekit: {
/**
* Typekit project id
*/
id: '<projectId>',
/**
* enable non-blocking renderer
* <link rel="preload" href="xxx" as="style" onload="this.rel='stylesheet'">
* default: true
*/
defer: true
},
// Google Fonts API V2
google: {
/**
* enable preconnect link injection
* <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
* default: true
*/
preconnect: false,
/**
* values: auto, block, swap(default), fallback, optional
* default: 'swap'
*/
display: 'block',
/**
* values: auto, block, swap(default), fallback, optional
* default: undefined
*/
text: 'ViteAwsom',
/**
* Fonts families lists
*/
families: [
// families can be either strings (only regular 400 will be loaded)
'Source Sans Pro',
// or objects
{
/**
* Family name (required)
*/
name: 'Roboto',
/**
* Family styles
*/
styles: 'ital,wght@0,400;1,200',
/**
* enable non-blocking renderer
* <link rel="preload" href="xxx" as="style" onload="this.rel='stylesheet'">
* default: true
*/
defer: true
}
]
},
})
],
}
```
## Ressources
- https://web.dev/optimize-webfont-loading/
- https://csswizardry.com/2020/05/the-fastest-google-fonts/
- _(unmaintained)_ https://www.npmjs.com/package/webfontloader

View File

@ -1,30 +0,0 @@
import { HtmlTagDescriptor } from 'vite';
declare type GoogleFontFamily = {
name: string;
styles?: string;
defer?: boolean;
};
declare type GoogleFonts = {
families: (string | GoogleFontFamily)[];
text?: string;
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
preconnect?: boolean;
};
declare type TypeKitFonts = {
id: string;
defer?: boolean;
};
declare type VitePluginFontsOptions = {
google?: GoogleFonts;
typekit?: TypeKitFonts;
};
declare function VitePluginFonts(options?: VitePluginFontsOptions): {
name: string;
transformIndexHtml(): HtmlTagDescriptor[];
};
export default VitePluginFonts;
export { VitePluginFonts as Plugin, VitePluginFontsOptions };

View File

@ -1,138 +0,0 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/google-fonts.ts
var GoogleFontsBase = "https://fonts.googleapis.com/css2";
function injectFonts({
families,
text,
preconnect = true,
display = "swap"
}) {
const specs = [];
const deferedSpecs = [];
const tags = [];
if (!Array.isArray(families)) {
console.warn("Google font families is required");
return tags;
}
if (families.length >= 0) {
for (const family of families) {
if (typeof family === "string") {
deferedSpecs.push(family);
continue;
}
if (!family)
continue;
const {
name,
styles,
defer = true
} = family;
if (!name) {
console.warn("A google font family name is missing");
continue;
}
let spec = name;
if (typeof styles === "string")
spec += `:${styles}`;
if (defer)
deferedSpecs.push(spec);
else
specs.push(spec);
}
}
if (preconnect && specs.length + deferedSpecs.length > 0) {
tags.push({
tag: "link",
attrs: {
rel: "preconnect",
href: "https://fonts.gstatic.com/",
crossorigin: true
}
});
}
if (deferedSpecs.length > 0) {
let href = `${GoogleFontsBase}?family=${deferedSpecs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href
}
});
}
if (specs.length > 0) {
let href = `${GoogleFontsBase}?family=${specs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href
}
});
}
return tags;
}
var google_fonts_default = injectFonts;
// src/typekit.ts
var TypekitFontBase = "https://use.typekit.net/";
function injectFonts2({
id,
defer = true
}) {
const tags = [];
if (typeof id !== "string") {
console.warn("A Typekit id is required");
return tags;
}
if (defer) {
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href: `${TypekitFontBase}${id}.css`
}
});
} else {
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href: `${TypekitFontBase}${id}.css`
}
});
}
return tags;
}
var typekit_default = injectFonts2;
// src/index.ts
function VitePluginFonts(options = {}) {
return {
name: "vite-plugin-fonts",
transformIndexHtml() {
const tags = [];
if (options.typekit)
tags.push(...typekit_default(options.typekit));
if (options.google)
tags.push(...google_fonts_default(options.google));
return tags;
}
};
}
var src_default = VitePluginFonts;
exports.Plugin = VitePluginFonts; exports.default = src_default;

View File

@ -1,138 +0,0 @@
// src/google-fonts.ts
var GoogleFontsBase = "https://fonts.googleapis.com/css2";
function injectFonts({
families,
text,
preconnect = true,
display = "swap"
}) {
const specs = [];
const deferedSpecs = [];
const tags = [];
if (!Array.isArray(families)) {
console.warn("Google font families is required");
return tags;
}
if (families.length >= 0) {
for (const family of families) {
if (typeof family === "string") {
deferedSpecs.push(family);
continue;
}
if (!family)
continue;
const {
name,
styles,
defer = true
} = family;
if (!name) {
console.warn("A google font family name is missing");
continue;
}
let spec = name;
if (typeof styles === "string")
spec += `:${styles}`;
if (defer)
deferedSpecs.push(spec);
else
specs.push(spec);
}
}
if (preconnect && specs.length + deferedSpecs.length > 0) {
tags.push({
tag: "link",
attrs: {
rel: "preconnect",
href: "https://fonts.gstatic.com/",
crossorigin: true
}
});
}
if (deferedSpecs.length > 0) {
let href = `${GoogleFontsBase}?family=${deferedSpecs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href
}
});
}
if (specs.length > 0) {
let href = `${GoogleFontsBase}?family=${specs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href
}
});
}
return tags;
}
var google_fonts_default = injectFonts;
// src/typekit.ts
var TypekitFontBase = "https://use.typekit.net/";
function injectFonts2({
id,
defer = true
}) {
const tags = [];
if (typeof id !== "string") {
console.warn("A Typekit id is required");
return tags;
}
if (defer) {
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href: `${TypekitFontBase}${id}.css`
}
});
} else {
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href: `${TypekitFontBase}${id}.css`
}
});
}
return tags;
}
var typekit_default = injectFonts2;
// src/index.ts
function VitePluginFonts(options = {}) {
return {
name: "vite-plugin-fonts",
transformIndexHtml() {
const tags = [];
if (options.typekit)
tags.push(...typekit_default(options.typekit));
if (options.google)
tags.push(...google_fonts_default(options.google));
return tags;
}
};
}
var src_default = VitePluginFonts;
export {
VitePluginFonts as Plugin,
src_default as default
};

View File

@ -1,34 +0,0 @@
{
"name": "vite-plugin-fonts",
"version": "0.2.2",
"description": "Webfont loader for vite",
"author": "stafyniaksacha",
"repository": "stafyniaksacha/vite-plugin-fonts",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"dev": "npm run build -- --watch",
"example:dev": "npm -C example run dev",
"example:build": "npm -C example run build",
"build": "tsup src/index.ts --dts --format cjs,esm",
"lint": "eslint --ext .ts ./src",
"lint:fix": "eslint --fix --ext .ts ./src"
},
"peerDependencies": {
"vite": "^2.0.0"
},
"devDependencies": {
"@antfu/eslint-config-ts": "^0.5.0",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"eslint": "^7.22.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"tsup": "^4.6.1",
"typescript": "^4.2.3",
"vite": "^2.0.5"
}
}

1
node_modules/vite-plugin-fonts generated vendored
View File

@ -1 +0,0 @@
.pnpm/vite-plugin-fonts@0.2.2/node_modules/vite-plugin-fonts

View File

@ -1,5 +0,0 @@
{
"devDependencies": {
"vite-plugin-fonts": "^0.2.2"
}
}

View File

@ -1,15 +0,0 @@
lockfileVersion: 5.3
specifiers:
vite-plugin-fonts: ^0.2.2
devDependencies:
vite-plugin-fonts: 0.2.2
packages:
/vite-plugin-fonts/0.2.2:
resolution: {integrity: sha512-fhzhsrTiuzlDjSO6g5sV5EVIIvbb8lmsaIY6eUTBM4lcF55x40UBpHrcyvNwIhQG211g0lu83XC7oZlkmvdkMA==}
peerDependencies:
vite: ^2.0.0
dev: true