diff --git a/.gitignore b/.gitignore index 697d68e..debc975 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ # lazy-lock.json # after # **/.DS_Store +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c3ac785..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Lua.diagnostics.globals": [ - "vim" - ], - "Lua.diagnostics.disable": [ - "different-requires", - "undefined-doc-name", - "inject-field" - ] -} \ No newline at end of file diff --git a/colors/vscode.vim b/colors/vscode.vim new file mode 100644 index 0000000..e69de29 diff --git a/colors/vscode.yml b/colors/vscode.yml new file mode 100644 index 0000000..974e785 --- /dev/null +++ b/colors/vscode.yml @@ -0,0 +1,392 @@ +information: + name: nvcode + background: dark + author: "Christian Chiarulli " + +palette: + fg: "#ABB2BF" + bg: "#1E1E1E" + + red: "#D16969" + error_red: "#F44747" + green: "#608B4E" + light_green: "#B5CEA8" + yellow: "#DCDCAA" + dark_yellow: "#D7BA7D" + orange: "#CE9178" + grey_blue: "#729CB3" + blue: "#569CD6" + light_blue: "#9CDCFE" + vivid_blue: "#4FC1FF" + purple: "#C586C0" + cyan: "#4EC9B0" + white: "#ABB2BF" + black: "#1E1E1E" + line_grey: "#5C6370" + gutter_fg_grey: "#858585" + cursor_grey: "#2C323C" + visual_grey: "#3E4452" + menu_grey: "#282C34" + special_grey: "#3B4048" + vertsplit: "#3E4452" + warning_orange: "#ff8800" + info_yellow: "#FFCC66" + search_blue: "#1da1f2" + git_green: "#81B88B" + symlink: "#29B8D8" + executable: "#23D18B" + tabfill: "#252526" + bg_inactive: "#2E2E2E" + cursor_fg: "#515052" + cursor_bg: "#AEAFAD" + indentlinehighlight: "#707070" + + +highlights: + Normal: "fg bg" + + Comment: "green - i" + Constant: "yellow" + String: "orange" + Character: "orange" + Number: "light_green" + Boolean: "light_green" + Float: "light_green" + Identifier: "light_blue" + Function: "yellow" + Statement: "purple" + Conditional: "purple" + Repeat: "purple" + Label: "light_blue" + Operator: "fg" + Keyword: "blue" + Exception: "purple" + PreProc: "yellow" + Include: "purple" + Define: "purple" + Title: "cyan" + Macro: "yellow" + PreCondit: "light_blue" + Type: "cyan" + StorageClass: "cyan" + Structure: "cyan" + Typedef: "cyan" + Special: "blue - i" + SpecialComment: "green" + Error: "error_red - br" + Todo: "red - bi" + Underlined: "light_blue . u" + Cursor: "cursor_fg cursor_bg" + + ColorColumn: "- cursor_grey" + CursorLineNr: "white - b" + SignColumn: "- bg" + Conceal: "line_grey" + CursorColumn: "- cursor_grey" + CursorLine: "- cursor_grey" + Directory: "blue" + DiffAdd: "black green" + DiffChange: "yellow - u" + DiffDelete: "black red" + DiffText: "black yellow" + ErrorMsg: "error_red" + VertSplit: "vertsplit" + Folded: "line_grey" + FoldColumn: "" + IncSearch: "- line_grey" + LineNr: "gutter_fg_grey" + NonText: "special_grey" + Pmenu: "white menu_grey" + PmenuSel: "black blue" + PmenuSbar: "- special_grey" + PmenuThumb: "- white" + Question: "purple" + QuickFixLine: "- line_grey" + Search: "- line_grey" + SpecialKey: "special_grey" + SpellBad: "error_red - u" + SpellCap: "dark_yellow" + SpellLocal: "dark_yellow" + SpellRare: "dark_yellow" + StatusLine: "white cursor_grey" + StatusLineNC: "line_grey" + StatusLineTerm: "white cursor_grey" + StatusLineTermNC: "cursor_grey" + TabLine: "line_grey" + TabLineSel: "white" + TabLineFill: "- tabfill" + Terminal: "white black" + Visual: "- visual_grey" + VisualNOS: "visual_grey" + WarningMsg: "yellow" + WildMenu: "black blue" + EndOfBuffer: "black" + + + # -- Start Treesitter -- + # Misc + TSComment: "green" + TSError: "error_red" + TSPunctDelimiter: "white" + TSPunctBracket: "white" + TSPunctSpecial: "white" + # Constants + TSConstant: "light_blue" + TSConstBuiltin: "light_blue" + # Not sure about this guy + TSConstMacro: "blue" + TSStringRegex: "red" + TSString: "orange" + TSStringEscape: "dark_yellow" + TSCharacter: "orange" + TSNumber: "light_green" + TSBoolean: "light_green" + TSFloat: "light_green" + TSAnnotation: "yellow" + TSAttribute: "cyan" + TSNamespace: "cyan" + # Functions + TSFuncBuiltin: "yellow" + TSFunction: "yellow" + TSFuncMacro: "blue" + TSParameter: "light_blue" + TSParameterReference: "light_blue" + TSMethod: "yellow" + TSField: "light_blue" + TSProperty: "light_blue" + TSConstructor: "blue" + # Keywords + TSConditional: "purple" + TSRepeat: "purple" + TSLabel: "light_blue" + # Does not work for yield and return they should be diff than class and def + TSKeyword: "blue" + TSKeywordFunction: "blue" + TSKeywordOperator: "blue" + TSOperator: "white" + TSException: "purple" + TSType: "cyan" + TSTypeBuiltin: "blue" + TSStructure: "cyan" + TSInclude: "purple" + # Variable + TSVariable: "light_blue" + TSVariableBuiltin: "light_blue" + # Text + TSText: "#FFFF00" + TSStrong: "#FFFF00" + TSEmphasis: "#FFFF00" + TSUnderline: "#FFFF00" + TSTitle: "#FFFF00" + TSLiteral: "orange" + TSURI: "- - u" + # Tags + TSTag: "blue" + TSTagDelimiter: "line_grey" + TSQueryLinterError: "warning_orange" + # -- END Treesitter -- + + # -- START Languages -- + # HTML (keep consistent with Markdown, below) + htmlArg: "dark_yellow" + htmlBold: "dark_yellow - b" + htmlEndTag: "white" + htmlH1: "blue" + htmlH2: "blue" + htmlH3: "blue" + htmlH4: "blue" + htmlH5: "blue" + htmlH6: "blue" + htmlItalic: "purple - i" + htmlLink: "cyan - u" + htmlSpecialChar: "dark_yellow" + htmlSpecialTagName: "blue" + htmlTag: "white" + htmlTagN: "blue" + htmlTagName: "blue" + htmlTitle: "white" + + # Markdown (keep consistent with HTML, above) + markdownBlockquote: "line_grey" + markdownBold: "dark_yellow - b" + markdownCode: "green" + markdownCodeBlock: "green" + markdownCodeDelimiter: "green" + markdownH1: "blue" + markdownH2: "blue" + markdownH3: "blue" + markdownH4: "blue" + markdownH5: "blue" + markdownH6: "blue" + markdownHeadingDelimiter: "red" + markdownHeadingRule: "line_grey" + markdownId: "purple" + markdownIdDeclaration: "blue" + markdownIdDelimiter: "purple" + markdownItalic: "purple - i" + markdownLinkDelimiter: "purple" + markdownLinkText: "blue" + markdownListMarker: "red" + markdownOrderedListMarker: "red" + markdownRule: "line_grey" + markdownUrl: "cyan - u" + # -- END Languages -- + + + # -- START CoC -- + CocExplorerIndentLine: "line_grey" + CocExplorerBufferRoot: "cyan" + CocExplorerFileRoot: "cyan" + CocExplorerBufferFullPath: "line_grey" + CocExplorerFileFullPath: "line_grey" + CocExplorerBufferReadonly: "purple" + CocExplorerBufferModified: "purple" + CocExplorerBufferNameVisible: "orange" + CocExplorerFileReadonly: "purple" + CocExplorerFileModified: "purple" + CocExplorerFileHidden: "line_grey" + CocExplorerHelpLine: "purple" + # -- END CoC -- + + # -- START Easymotion -- + EasyMotionTarget: "error_red - b" + EasyMotionTarget2First: "error_red - b" + EasyMotionTarget2Second: "error_red - b" + EasyMotionShade: "" + # EasyMotionIncSearch: + # EasyMotionMoveHL: + + # -- END Easymotion -- + + # -- START Startify -- + StartifyNumber: "light_green" + StartifySelect: "green" + StartifyBracket: "blue" + StartifySpecial: "cyan" + StartifyVar: "blue" + StartifyPath: "blue" + StartifyFile: "cyan" + StartifySlash: "blue" + StartifyHeader: "light_blue" + StartifySection: "purple" + StartifyFooter: "green" + # -- END Startify -- + # -- START WhichKey -- + WhichKey: "purple" + WhichKeySeperator: "green" + WhichKeyGroup: "vivid_blue" + WhichKeyDesc: "blue" + # -- END WhichKey -- + # + # old stuff + diffAdded: "green" + diffRemoved: "red" + diffFileId: "blue - br" + diffFile: "special_grey" + diffNewFile: "green" + diffOldFile: "red" + # ToolbarLine: ". darkgray" + # ToolbarButton: "suvagray - r" + debugPc: "- cyan" + debugBreakpoint: "red - r" + + GitSignsAdd: "#587C0C" + GitSignsChange: "#0C7D9D" + GitSignsDelete: "#94151B" + + # LspDiagnosticsUnderlineError: "error_red" + # LspDiagnosticsUnderlineWarning: "orange" + # LspDiagnosticsUnderlineInformation: "yellow" + LspDiagnosticsUnderlineHint: "grey_blue" + + LspDiagnosticsSignError: "error_red" + LspDiagnosticsSignWarning: "warning_orange" + LspDiagnosticsSignInformation: "info_yellow" + LspDiagnosticsSignHint: "vivid_blue" + + LspDiagnosticsVirtualTextError: "error_red" + LspDiagnosticsVirtualTextWarning: "warning_orange" + LspDiagnosticsVirtualTextInformation: "info_yellow" + LspDiagnosticsVirtualTextHint: "vivid_blue" + + + QuickScopePrimary: "#00C7DF - u" + QuickScopeSecondary: "#eF5F70 - u" + + MatchWord: "- - u" + MatchParen: "- - u" + MatchWordCur: "- - u" + MatchParenCur: "- - u" + + NvimTreeImageFile: "purple" + NvimTreeGitDirty: "git_green" + NvimTreeGitDeleted: "git_green" + NvimTreeGitStaged: "git_green" + NvimTreeGitMerge: "git_green" + NvimTreeGitRenamed: "git_green" + NvimTreeGitNew: "git_green" + NvimTreeIndentMarker: "line_grey" + NvimTreeSymlink: "symlink" + NvimTreeFolderIcon: "blue" + NvimTreeRootFolder: "fg - b" + NvimTreeExecFile: "executable" + NvimTreeSpecialFile: "info_yellow" + + BufferCurrent: "fg bg" + BufferCurrentIndex: "blue bg" + BufferCurrentMod: "fg bg" + BufferCurrentSign: "blue bg" + BufferCurrentTarget: "red bg b" + + BufferVisible: "fg bg" + BufferVisibleIndex: "fg bg" + BufferVisibleMod: "fg bg" + BufferVisibleSign: "fg bg" + BufferVisibleTarget: "red bg b" + + BufferInactive: "gutter_fg_grey bg_inactive" + BufferInactiveIndex: "gutter_fg_grey bg_inactive" + BufferInactiveMod: "gutter_fg_grey bg_inactive" + BufferInactiveSign: "gutter_fg_grey bg_inactive" + BufferInactiveTarget: "red bg_inactive b" + + # BufferTabpages: "blue bg_inactive b" + # BufferTabpageFill: "gutter_fg_grey bg_inactive" + + CodiVirtualText: "#6395EC" + IndentBlanklineContextChar: "indentlinehighlight" + + + # terminal: "bg red green yellow blue magenta cyan silver gray red green yellow blue magenta cyan fg" + # -- Other junk you can define -- + # Debug + # Ignore + # Tag + # Delimiter + # SpecialChar + # Cursor", { "fg": s:black, "bg": s:blue }) " the character under the cursor + # CursorIM", {}) " like Cursor, but used when in IME mode + # FoldColumn", {}) " 'foldcolumn' + # CursorLineNr", {}) " Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. + # MoreMsg", {}) " more-prompt + # ModeMsg", {}) " 'showmode' message (e.g., "-- INSERT --") + # ErrorMsg: "red - br" + # WarningMsg: "orange - br" + # ModeMsg: "yellow - br" + # MoreMsg: "green - br" + # Question: "cyan - br" + # Directory: "blue - b" + + # VimWiki + VimwikiHeader1: "orange - b" + VimwikiHeader2: "green - b" + VimwikiHeader3: "blue - b" + VimwikiHeader4: "cyan - b" + VimwikiHeader5: "dark_yellow - b" + VimwikiHeader6: "purple - b" + VimwikiLink: "vivid_blue" + VimwikiHeaderChar: "line_grey" + VimwikiHR: "yellow" + VimwikiList: "orange" + VimwikiTag: "orange" + VimwikiMarkers: "line_grey" \ No newline at end of file diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..407e6e9 --- /dev/null +++ b/deno.json @@ -0,0 +1,6 @@ +{ + "tasks": { + "generate": "./scripts/generate ./colors/vscode.yml > ./colors/vscode", + "install": "deno run --allow-write=~/.config/nvim scripts/install.ts" + } +} \ No newline at end of file diff --git a/install b/install index f8e9740..37b81ed 100755 --- a/install +++ b/install @@ -1,4 +1,4 @@ -!#/usr/bin/sh +#!/usr/bin/sh git commit -am ".." diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index ce4b98f..ca38cc8 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -8,4 +8,4 @@ M.mappings=require("custom.mappings"); -return M \ No newline at end of file +return M diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua index ff6d539..ab2245d 100644 --- a/lua/custom/plugins.lua +++ b/lua/custom/plugins.lua @@ -55,11 +55,15 @@ local plugins={ }, { 'nvim-treesitter/nvim-treesitter', - } + }, + { + "nvim-treesitter/playground", + dependencies={"nvim-treesitter/nvim-treesitter"} + }, }; -return plugins; \ No newline at end of file +return plugins; diff --git a/scripts/generate b/scripts/generate new file mode 100755 index 0000000..992cdd6 --- /dev/null +++ b/scripts/generate @@ -0,0 +1,182 @@ +#!/usr/bin/env ruby + +require 'yaml' + +$data = YAML.load(ARGF, symbolize_names: true) + +$information = $data[:information] +$palette = $data[:palette] +$highlights = $data[:highlights] +$terminal = $data[:terminal] + +def error(message) + $stderr.puts message + exit 1 +end + +def hex_to_rgb(hex) + r = hex.match(/^#(\h{2})(\h{2})(\h{2})$/) + return r.captures.map { |e| e.to_i(16) } if r + r = hex.match(/^#(\h)(\h)(\h)$/) + return r.captures.map { |e| 0x11 * e.to_i(16) } if r + return nil +end + +def rgb_to_hex(red, green, blue) + rgb = (red << 16) | (green << 8) | (blue << 0) + return '#' + (0x1000000 + rgb).to_s(16)[1..-1] +end + +# From tmux +def rgb_to_x256(*orig) + values = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff] + + ir, ig, ib = orig.map do |e| + e < 48 ? 0 : e < 115 ? 1 : (e - 35) / 40 + end + + average = orig.sum / 3 + gray_index = average > 238 ? 23 : (average - 3) / 10 + color_index = 36 * ir + 6 * ig + ib + + r, g, b = orig + cr, cg, cb = values[ir], values[ig], values[ib] + gv = 8 + 10 * gray_index + color_err = (cr - r) ** 2 + (cg - g) ** 2 + (cb - b) ** 2 + gray_err = (gv - r) ** 2 + (gv - g) ** 2 + (gv - b) ** 2 + + color_err <= gray_err ? 16 + color_index : 232 + gray_index +end + +def hsl_to_rgb(h, s, l) + s = s / 100.0 + l = l / 100.0 + + r, g, b = 0.0, 0.0, 0.0 + + if (s == 0.0) + # achromatic + r, g, b = l, l, l + else + c = (1 - (2 * l - 1).abs) * s + h /= 60.0 + x = c * (1 - (h % 2 - 1).abs) + m = l - (c / 2) + + if h <= 1 + r, g, b = c, x, 0 + elsif h <= 2 + r, g, b = x, c, 0 + elsif h <= 3 + r, g, b = 0, c, x + elsif h <= 4 + r, g, b = 0, x, c + elsif h <= 5 + r, g, b = x, 0, c + elsif h <= 6 + r, g, b = c, 0, x + end + + r, g, b = r + m, g + m, b + m + end + + return [r, g, b].map { |e| e * 255 } +end + +def get_color(color) + if color.start_with?('#') + return hex_to_rgb(color) + end + r = $palette[color.to_sym] + error("Color not found '#{color}'") if !r + if r.kind_of?(Array) + return hsl_to_rgb(*r) + elsif r.start_with?('#') + return hex_to_rgb(r) + elsif r =~ /^hsl\((\d+), (\d+), (\d+)\)$/ + return hsl_to_rgb($1.to_i, $2.to_i, $3.to_i) + end + return nil +end + +class Highlight + def initialize(name, conf) + @name = name.to_s + return if !conf + fg, bg, style, sp = conf.split(' ') + @params = {} + @params.merge!(hi_color('fg', fg)) + @params.merge!(hi_color('bg', bg)) + @params.merge!(hi_style(style)) + @params.merge!(hi_color('sp', sp)) + end + + def to_s + "hi #{@name} " + @params.map { |e| '%s=%s' % e }.join(' ') + end + + private + + def hi_color(kind, color) + return {} if color == '.' + return {} if kind == 'sp' and !color + if color and color != '-' + rgb = get_color(color) + rgb.map!(&:round) + color = rgb_to_hex(*rgb) + c_color = rgb_to_x256(*rgb) + else + color = 'NONE' + c_color = 'NONE' + end + params = { 'gui' + kind => color } + params['cterm' + kind] = c_color unless kind == 'sp' + return params + end + + def hi_style(style) + return {} if style == '.' + if style and style != '-' + attributes = { + b: 'bold', + u: 'underline', + r: 'reverse', + i: 'italic', + c: 'undercurl', + s: 'standout', + } + style = style.chars.map { |e| attributes[e.to_sym] }.join(',') + else + style = 'NONE' + end + return { 'gui' => style, 'cterm' => style } + end + +end + +$highlights = $highlights.map { |e| Highlight.new(*e) } + +puts <