From 6e788a6e4e78d7557840f504847754fae22269f3 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Sun, 10 Jul 2022 19:34:48 +0200 Subject: refactor, and change colors --- after/plugin/cmp.lua | 131 +++++++++++++++++++++++++++++++++++++++ after/plugin/colors.lua | 16 ----- after/plugin/completition.lua | 138 ------------------------------------------ after/plugin/nightfox.lua | 16 +++++ lua/alpha/colors.lua | 25 ++++++++ plugin/colors.vim | 28 --------- 6 files changed, 172 insertions(+), 182 deletions(-) create mode 100644 after/plugin/cmp.lua delete mode 100644 after/plugin/colors.lua delete mode 100644 after/plugin/completition.lua create mode 100644 after/plugin/nightfox.lua create mode 100644 lua/alpha/colors.lua delete mode 100644 plugin/colors.vim diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua new file mode 100644 index 0000000..ffafe96 --- /dev/null +++ b/after/plugin/cmp.lua @@ -0,0 +1,131 @@ +local ok, cmp = pcall(require, "cmp") +if not ok then + return +end + +local _ = require("alpha.colors") + +local lspkind = require("lspkind") +local luasnip = require("luasnip") +local cmp_autopairs = require("nvim-autopairs.completion.cmp") + +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) + +cmp.setup({ + mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.close() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.choice_active() then + luasnip.change_choice(1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), + [""] = cmp.mapping.complete(), + }, + sources = { + { name = "nvim_lua" }, + { name = "nvim_lsp" }, + { name = "path" }, + { name = "luasnip" }, + { + name = "buffer", + keyword_length = 5, + 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, + }, + }, + }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = { + format = lspkind.cmp_format({ + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + ["vim-dadbod-completion"] = "[DB]", + }, + }), + }, + + experimental = { + native_menu = false, + + ghost_text = true, + }, +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = "buffer" }, + }), +}) + +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), +}) + +cmp.setup.filetype({ "sql", "mysql", "plsql" }, { + sources = cmp.config.sources({ + { name = "vim-dadbod-completion" }, + }, { + { name = "buffer" }, + }), +}) + +-- Setup lspconfig. +local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) +-- Replace with each lsp server you've enabled. +require("lspconfig")["emmet_ls"].setup({ + capabilities = capabilities, +}) + diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua deleted file mode 100644 index d6d0d18..0000000 --- a/after/plugin/colors.lua +++ /dev/null @@ -1,16 +0,0 @@ -local Color, colors, Group, groups, styles = require('colorbuddy').setup() - --- Use Color.new(, <#rrggbb>) to create new colors --- They can be accessed through colors. -Color.new('background', '#282c34') -Color.new('red', '#cc6666') -Color.new('green', '#99cc99') -Color.new('yellow', '#f0c674') - --- Define highlights in terms of `colors` and `groups` -Group.new('Comment' , colors.yellow , colors.background , styles.bold) -Group.new('Special' , groups.Comment , groups.Comment , groups.Comment) -Group.new('NonText' , groups.Comment , groups.Comment , groups.Comment) - --- Define highlights in relative terms of other colors -Group.new('Error' , colors.red:light() , nil , styles.bold) diff --git a/after/plugin/completition.lua b/after/plugin/completition.lua deleted file mode 100644 index 8b260d2..0000000 --- a/after/plugin/completition.lua +++ /dev/null @@ -1,138 +0,0 @@ -local ok, cmp = pcall(require, "cmp") -if not ok then - return -end - -local lspkind = require("lspkind") -local luasnip = require("luasnip") -local cmp_autopairs = require("nvim-autopairs.completion.cmp") - -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) - -cmp.setup({ - mapping = { - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.close() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.choice_active() then - luasnip.change_choice(1) - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - [""] = cmp.mapping.complete(), - }, - sources = { - { name = "nvim_lua" }, - { name = "nvim_lsp" }, - { name = "path" }, - { name = "luasnip" }, - { - name = "buffer", - keyword_length = 5, - 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, - }, - }, - }, - - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - - formatting = { - format = lspkind.cmp_format({ - with_text = true, - menu = { - buffer = "[buf]", - nvim_lsp = "[LSP]", - nvim_lua = "[api]", - path = "[path]", - luasnip = "[snip]", - ["vim-dadbod-completion"] = "[DB]", - }, - }), - }, - - experimental = { - native_menu = false, - - ghost_text = true, - }, -}) - --- Set configuration for specific filetype. -cmp.setup.filetype("gitcommit", { - sources = cmp.config.sources({ - { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { name = "buffer" }, - }), -}) - --- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), -}) - -cmp.setup.filetype({ "sql", "mysql", "plsql" }, { - sources = cmp.config.sources({ - { name = "vim-dadbod-completion" }, - }, { - { name = "buffer" }, - }), -}) - --- Setup lspconfig. -local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) --- Replace with each lsp server you've enabled. -require("lspconfig")["emmet_ls"].setup({ - capabilities = capabilities, -}) - -local Group = require("colorbuddy.group").Group -local g = require("colorbuddy.group").groups -local s = require("colorbuddy.style").styles - -Group.new("CmpItemAbbr", g.Comment) -Group.new("CmpItemAbbrDeprecated", g.Error) -Group.new("CmpItemAbbrMatchFuzzy", g.CmpItemAbbr.fg:dark(), nil, s.italic) -Group.new("CmpItemKind", g.Special) -Group.new("CmpItemMenu", g.NonText) diff --git a/after/plugin/nightfox.lua b/after/plugin/nightfox.lua new file mode 100644 index 0000000..beb5c44 --- /dev/null +++ b/after/plugin/nightfox.lua @@ -0,0 +1,16 @@ +local ok, nightfox = pcall(require, "nightfox") +if not ok then + return +end + +nightfox.setup({ + options = { + styles = { + comments = "italic", + keywords = "bold", + types = "italic,bold", + } + } +}) + +vim.cmd("colorscheme duskfox") diff --git a/lua/alpha/colors.lua b/lua/alpha/colors.lua new file mode 100644 index 0000000..6e26311 --- /dev/null +++ b/lua/alpha/colors.lua @@ -0,0 +1,25 @@ +local Color, colors, Group, groups, styles = require('colorbuddy').setup() + +-- Use Color.new(, <#rrggbb>) to create new colors +-- They can be accessed through colors. +Color.new('background', '#282c34') +Color.new('red', '#cc6666') +Color.new('green', '#99cc99') +Color.new('yellow', '#f0c674') + +-- Define highlights in terms of `colors` and `groups` +Group.new('Comment' , colors.yellow , colors.background , styles.bold) +Group.new('Special' , groups.Comment , groups.Comment , groups.Comment) +Group.new('NonText' , groups.Comment , groups.Comment , groups.Comment) + +-- Define highlights in relative terms of other colors +Group.new('Error' , colors.red:light() , nil , styles.bold) + +local g = require("colorbuddy.group").groups +local s = require("colorbuddy.style").styles + +Group.new("CmpItemAbbr", g.Comment) +Group.new("CmpItemAbbrDeprecated", g.Error) +Group.new("CmpItemAbbrMatchFuzzy", g.CmpItemAbbr.fg:dark(), nil, s.italic) +Group.new("CmpItemKind", g.Special) +Group.new("CmpItemMenu", g.NonText) diff --git a/plugin/colors.vim b/plugin/colors.vim deleted file mode 100644 index cc04474..0000000 --- a/plugin/colors.vim +++ /dev/null @@ -1,28 +0,0 @@ -fun! ColorMyPencils() - " let g:gruvbox_contrast_dark = 'hard' - " let g:gruvbox_bold = 0 - if exists('+termguicolors') - let &t_8f = "\[38;2;%lu;%lu;%lum" - let &t_8b = "\[48;2;%lu;%lu;%lum" - endif - - set background=dark - colorscheme nightfox - - " Transparency - "highlight Normal ctermbg=NONE guibg=NONE - "highlight EndOfBuffer ctermbg=NONE guibg=NONE - - highlight ColorColumn ctermbg=0 guibg=grey - " highlight Normal guibg=none - " highlight LineNr guifg=#ff8659 - " highlight LineNr guifg=#aed75f - highlight LineNr guifg=#5eacd3 - highlight netrwDir guifg=#5eacd3 - highlight qfFileName guifg=#aed75f - hi TelescopeBorder guifg=#5eacd -endfun - -call ColorMyPencils() - -" nnoremap cc :call ColorMyPencils() -- cgit v1.2.3