From ed8622428019241ae51013e1f08d7fe4ca79a781 Mon Sep 17 00:00:00 2001 From: deadguy Date: Sat, 14 May 2022 20:15:05 -0300 Subject: [PATCH] 99% listo nvim 0.7. me faltarian los atajos y autocommands, pero eso queda para otro momento. Tambien actualize una opcion de fd --- lf/lfrc | 3 +- nvim/init.lua | 23 ++- nvim/lua/plugins/gitsigns_nvim.lua | 1 - nvim/lua/plugins/icons.lua | 247 ++++++++++++++++++++++++++++ nvim/lua/plugins/lsp/lsp-config.lua | 2 +- nvim/lua/plugins/lsp/lsp-utils.lua | 1 - nvim/lua/plugins/lsp/null-ls.lua | 17 +- nvim/lua/plugins/lsp/nvim-cmp.lua | 29 +++- nvim/lua/plugins/telescope.lua | 39 ++--- nvim/lua/plugins/treesitter.lua | 3 - nvim/lua/plugins/trouble.lua | 11 -- nvim/lua/plugins/web-devicons.lua | 88 ---------- nvim/plugin/color.vim | 17 ++ pipe-viewer/pipe-viewer.conf | 4 +- 14 files changed, 329 insertions(+), 156 deletions(-) create mode 100644 nvim/lua/plugins/icons.lua delete mode 100644 nvim/lua/plugins/trouble.lua delete mode 100644 nvim/lua/plugins/web-devicons.lua diff --git a/lf/lfrc b/lf/lfrc index f4be586..11c30b2 100644 --- a/lf/lfrc +++ b/lf/lfrc @@ -236,6 +236,7 @@ map y map c map / map r +map G cmap cmd-escape @@ -282,7 +283,7 @@ map a push A # after extention map B bulkrename map L :Link map f fzf_jump -map / $lf -remote "send $id select \"$(FZF_DEFAULT_COMMAND='fd --max-depth=1' fzf)\"" +map / $lf -remote "send $id select \"$(FZF_DEFAULT_COMMAND='fd --max-depth=1 --strip-cwd-prefix' fzf)\"" map F $find | lf -remote "send $id select $(fzf --reverse --border --margin 2% --inline-info --color border:#005688,bg+:#16252E,fg+:#26c6da,hl+:#ffffff,hl:#26c6da)" map Gb :git_branch diff --git a/nvim/init.lua b/nvim/init.lua index 6b5f8c0..d374c85 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,9 +1,8 @@ -vim.g.did_load_filetypes = 1 vim.g.mapleader = " " vim.g.maplocalleader = "," vim.o.termguicolors = true -local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" +local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.fn.execute("!git clone --depth 1 https://github.com/wbthomason/packer.nvim " .. install_path) vim.api.nvim_command([[packadd packer.nvim]]) @@ -15,6 +14,8 @@ if not status_ok then end packer.init({ + enable = true, + threshold= 0, display = { open_fn = function() return require("packer.util").float({ border = "single" }) @@ -24,21 +25,19 @@ packer.init({ return packer.startup({ function(use) - use({ "wbthomason/packer.nvim", opt = true }) + use({ "wbthomason/packer.nvim" }) use({ "lewis6991/impatient.nvim", config = function() require("impatient") end, }) + use({ "nathom/filetype.nvim" }) use("nvim-lua/plenary.nvim") use({ "ellisonleao/gruvbox.nvim" }) - use({ - "kyazdani42/nvim-web-devicons", - after = "gruvbox.nvim", - opt = true, + use({ "kyazdani42/nvim-web-devicons", config = function() - require("plugins.webdevicons") + require("plugins.icons") end, }) use({ @@ -50,7 +49,7 @@ return packer.startup({ }) use({ "norcalli/nvim-colorizer.lua", - event = "CursorHold", + event = "BufReadPre", config = function() require("plugins.colorizer") end, @@ -58,7 +57,7 @@ return packer.startup({ use({ "tpope/vim-fugitive", opt = true, cmd = { "Git", "Gdiff", "Gblame", "Glog", "Git mergetool" } }) use({ "lewis6991/gitsigns.nvim", - event = { "BufRead" }, + event = "BufReadPre", config = function() require("plugins.gitsigns_nvim") end, @@ -80,7 +79,6 @@ return packer.startup({ }) use({ "neovim/nvim-lspconfig", - event = "BufRead", config = function() require("plugins.lsp.lsp-config") end, @@ -96,7 +94,6 @@ return packer.startup({ use({ { "hrsh7th/nvim-cmp", - event = "InsertEnter", config = function() require("plugins.lsp.nvim-cmp") end, @@ -115,6 +112,7 @@ return packer.startup({ { "f3fora/cmp-spell", after = "nvim-cmp" }, { "hrsh7th/cmp-nvim-lua", after = "nvim-cmp" }, { "saadparwaiz1/cmp_luasnip", after = "LuaSnip"}, + { "hrsh7th/cmp-nvim-lsp-signature-help", after = "lsp_signature.nvim" }, }) use({ "windwp/nvim-autopairs", @@ -124,6 +122,5 @@ return packer.startup({ require("plugins.autopairs") end, }) - use({ "nathom/filetype.nvim" }) end, }) diff --git a/nvim/lua/plugins/gitsigns_nvim.lua b/nvim/lua/plugins/gitsigns_nvim.lua index 04fe2fb..632e00a 100644 --- a/nvim/lua/plugins/gitsigns_nvim.lua +++ b/nvim/lua/plugins/gitsigns_nvim.lua @@ -14,7 +14,6 @@ require("gitsigns").setup({ }, }, update_debounce = 200, - use_internal_diff = true, keymaps = { noremap = true, ["n }g"] = { expr = true, "&diff ? '}c' : 'lua require\"gitsigns\".next_hunk()'" }, diff --git a/nvim/lua/plugins/icons.lua b/nvim/lua/plugins/icons.lua new file mode 100644 index 0000000..bbc98c6 --- /dev/null +++ b/nvim/lua/plugins/icons.lua @@ -0,0 +1,247 @@ +local ok, web_devicons = pcall(require, "nvim-web-devicons") + +if not ok then + return +end + +web_devicons.setup { + override = { + html = { + icon = "", + name = "html", + }, + css = { + icon = "", + name = "css", + }, + scss = { + icon = "", + name = "scss", + }, + sass = { + icon = "", + name = "sass", + }, + js = { + icon = "", + name = "js", + }, + ts = { + icon = "ﯤ", + name = "ts", + }, + kt = { + icon = "󱈙", + name = "kt", + }, + png = { + icon = "", + name = "png", + }, + jpg = { + icon = "", + name = "jpg", + }, + jpeg = { + icon = "", + name = "jpeg", + }, + mp3 = { + icon = "", + name = "mp3", + }, + mp4 = { + icon = "", + name = "mp4", + }, + out = { + icon = "", + name = "out", + }, + rb = { + icon = "", + name = "rb", + }, + vue = { + icon = "﵂", + name = "vue", + }, + py = { + icon = "", + name = "py", + }, + toml = { + icon = "", + name = "toml", + }, + lock = { + icon = "", + name = "lock", + }, + zip = { + icon = "", + name = "zip", + }, + xz = { + icon = "", + name = "xz", + }, + deb = { + icon = "", + name = "deb", + }, + rpm = { + icon = "", + name = "rpm", + }, + lua = { + icon = "", + name = "lua", + }, + txt = { + icon = "", + name = "txt", + }, + md = { + icon = "", + name = "markdown", + }, + graphql = { + icon = "", + name = "graphql", + }, + env = { + icon = "", + name = "dotenvexample", + }, + [".env.production"] = { + icon = "", + name = "envprod", + }, + [".env.development"] = { + icon = "", + name = "envdev", + }, + [".env.testing"] = { + icon = "", + name = "envtest", + }, + [".env.example"] = { + icon = "", + name = "dotenvexample", + }, + [".env"] = { + icon = "", + name = "dotenv", + }, + ["docker-compose.yml"] = { + icon = "", + name = "dockercompose", + }, + [".dockerignore"] = { + icon = "", + name = "dockerignore", + }, + [".prettierignore"] = { + icon = "", + name = "prettierignore", + }, + [".prettierrc"] = { + icon = "", + name = "prettier", + }, + [".prettierrc.json"] = { + icon = "", + name = "prettierjson", + }, + [".prettierrc.js"] = { + icon = "", + name = "prettierrcjs", + }, + ["prettier.config.js"] = { + icon = "", + name = "prettierjsconfig", + }, + [".prettier.yaml"] = { + icon = "", + name = "prettieryaml", + }, + ["test.js"] = { + icon = "", + name = "javascripttest", + }, + ["test.jsx"] = { + icon = "", + name = "reactrest", + }, + ["test.ts"] = { + icon = "", + name = "typescripttest", + }, + ["test.tsx"] = { + icon = "", + name = "reacttypescripttest", + }, + ["spec.js"] = { + icon = "", + name = "javascriptspectest", + }, + ["spec.jsx"] = { + icon = "", + name = "reactspectest", + }, + ["spec.ts"] = { + icon = "", + name = "typescriptspectest", + }, + ["spec.tsx"] = { + icon = "", + name = "reacttypescriptspectest", + }, + ["yarn-error.log"] = { + icon = "", + name = "yarnerrorlog", + }, + ["yarn.lock"] = { + icon = "", + name = "yarnlock", + }, + ["package.json"] = { + icon = "", + name = "npm_packagejson", + }, + [".gitignore"] = { + icon = "", + name = "gitignore", + }, + [".gitattributes"] = { + icon = "", + name = "gitattributes", + }, + ["Dockerfile"] = { + icon = "", + name = "dockerfilex", + }, + [".nvmrc"] = { + icon = "", + name = "nvmrc", + }, + [".eslintrc.js"] = { + icon = "ﯶ", + name = "eslintrcjs", + }, + [".travis.yml"] = { + icon = "", + name = "travis", + }, + ["babel.config.js"] = { + icon = "", + name = "babelconfig", + }, + [".commitlintrc.json"] = { + icon = "ﰚ", + name = "commitlinrcjson", + }, + }, + default = true, +} diff --git a/nvim/lua/plugins/lsp/lsp-config.lua b/nvim/lua/plugins/lsp/lsp-config.lua index 51d2b94..a88cd62 100644 --- a/nvim/lua/plugins/lsp/lsp-config.lua +++ b/nvim/lua/plugins/lsp/lsp-config.lua @@ -97,7 +97,7 @@ require("lspconfig/configs").ls_emmet = { }, } -local servers = { "html", "cssls", "gopls", "tailwindcss", "vimls", "jsonls" } +local servers = { "html", "cssls", "tailwindcss", "vimls", "jsonls" } for _, lsp in ipairs(servers) do lsconf[lsp].setup({ on_attach = on_attach, diff --git a/nvim/lua/plugins/lsp/lsp-utils.lua b/nvim/lua/plugins/lsp/lsp-utils.lua index 70cc840..ea5fbfb 100644 --- a/nvim/lua/plugins/lsp/lsp-utils.lua +++ b/nvim/lua/plugins/lsp/lsp-utils.lua @@ -19,7 +19,6 @@ vim.diagnostic.config({ virtual_text = false, update_in_insert = true, severity_sort = true, - source = "always", }) local U = {} diff --git a/nvim/lua/plugins/lsp/null-ls.lua b/nvim/lua/plugins/lsp/null-ls.lua index ea85082..ec72396 100644 --- a/nvim/lua/plugins/lsp/null-ls.lua +++ b/nvim/lua/plugins/lsp/null-ls.lua @@ -1,6 +1,7 @@ local fmt = require("null-ls").builtins.formatting local dgn = require("null-ls").builtins.diagnostics local cda = require("null-ls").builtins.code_actions +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) require("null-ls").setup({ sources = { @@ -15,13 +16,12 @@ require("null-ls").setup({ fmt.eslint_d, fmt.rustywind, fmt.stylua, - fmt.goimports, - fmt.gofumpt, fmt.shfmt, -- # DIAGNOSTICS # dgn.eslint_d, + dgn.tidy, + dgn.luacheck, dgn.shellcheck, - dgn.golangci_lint, dgn.luacheck.with({ extra_args = { "--globals", "vim", "--std", "luajit" }, }), @@ -33,5 +33,16 @@ require("null-ls").setup({ on_attach = function(client, bufnr) -- require("plugins.lsp.lsp-utils").fmt_on_save(client) require("plugins.lsp.lsp-utils").mappings(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() + -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead + vim.lsp.buf.formatting_sync() + end, + }) + end end, }) diff --git a/nvim/lua/plugins/lsp/nvim-cmp.lua b/nvim/lua/plugins/lsp/nvim-cmp.lua index e12d9c7..3b8e9f2 100644 --- a/nvim/lua/plugins/lsp/nvim-cmp.lua +++ b/nvim/lua/plugins/lsp/nvim-cmp.lua @@ -26,8 +26,24 @@ local cmp_kinds = { TypeParameter = " ", } +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 +local luasnip = require("luasnip") local cmp = require("cmp") cmp.setup({ + enabled = function() + -- disable completion in comments + local context = require 'cmp.config.context' + -- keep command mode completion enabled when cursor is in a comment + if vim.api.nvim_get_mode().mode == 'c' then + return true + else + return not context.in_treesitter_capture("comment") + and not context.in_syntax_group("Comment") + end + end, snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) @@ -53,16 +69,18 @@ cmp.setup({ behavior = cmp.ConfirmBehavior.Replace, select = true, }), - [""] = function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then + elseif luasnip.expand_or_locally_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + elseif has_words_before() then + cmp.complete() else fallback() end - end, - [""] = function(fallback) + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then @@ -70,12 +88,13 @@ cmp.setup({ else fallback() end - end, + end, {"i", "s"}), }, sources = cmp.config.sources({ { name = "luasnip", max_item_count = 5 }, { name = "nvim_lsp", max_item_count = 5 }, { name = "path", max_item_count = 10 }, { name = "buffer", max_item_count = 10 }, + { name = "nvim_lsp_signature_help" }, }), }) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index c79d277..295bc0e 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,27 +1,6 @@ local actions = require("telescope.actions") local previewers = require("telescope.previewers") local builtin = require("telescope.builtin") -local Job = require("plenary.job") - -local new_maker = function(filepath, bufnr, opts) - filepath = vim.fn.expand(filepath) - Job - :new({ - command = "file", - args = { "--mime-type", "-b", filepath }, - on_exit = function(j) - local mime_type = vim.split(j:result()[1], "/")[1] - if mime_type == "text" then - previewers.buffer_previewer_maker(filepath, bufnr, opts) - else - vim.schedule(function() - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" }) - end) - end - end, - }) - :sync() -end require("telescope").setup({ defaults = require("telescope.themes").get_ivy({ @@ -62,14 +41,11 @@ require("telescope").setup({ hidden = true, }, }, -prompt_prefix = "  ", + prompt_prefix = "  ", selection_caret = " → ", entry_prefix = " ", file_ignore_patterns = { "node_modules", ".git/", "dist/" }, - color_devicons = true, - file_ignore_patterns = { "node_modules", ".git" }, set_env = { ["COLORTERM"] = "truecolor" }, - buffer_previewer_maker = new_maker, mappings = { i = { [""] = false, @@ -78,13 +54,12 @@ prompt_prefix = "  ", [""] = actions.close, [""] = actions.toggle_selection + actions.move_selection_next, [""] = require("telescope.actions.layout").toggle_preview, - } + }, }, extensions = { file_browser = { hidden = true, theme = "ivy", - dir_icon = "  ", }, }, }), @@ -116,9 +91,17 @@ Delta_git_bcommits = function(opts) builtin.git_bcommits(opts) end +Project_files = function() + local opts = { show_untracked = false } -- define here if you want to define something + local ok = pcall(require("telescope.builtin").git_files, opts) + if not ok then + require("telescope.builtin").find_files(opts) + end +end + local default_opts = { noremap = true, silent = true } vim.api.nvim_set_keymap("n", "", "Telescope help_tags", default_opts) -vim.api.nvim_set_keymap("n", "", "Telescope file_browser", default_opts) +vim.api.nvim_set_keymap("n", "", "lua Project_files()", default_opts) vim.api.nvim_set_keymap( "n", "", diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 4659a1e..0603557 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -2,9 +2,6 @@ require("nvim-treesitter.configs").setup({ ensure_installed = { "bash", "css", - "go", - "gomod", - "gowork", "html", "json", "json5", diff --git a/nvim/lua/plugins/trouble.lua b/nvim/lua/plugins/trouble.lua deleted file mode 100644 index 7e832fb..0000000 --- a/nvim/lua/plugins/trouble.lua +++ /dev/null @@ -1,11 +0,0 @@ -require("trouble").setup()({ - use_lsp_diagnostic_signs = true, -}) - -local opts = { noremap = true, silent = true } -vim.api.nvim_set_keymap("n", "xx", "Trouble", opts) -vim.api.nvim_set_keymap("n", "xw", "Trouble lsp_workspace_diagnostics", opts) -vim.api.nvim_set_keymap("n", "xd", "Trouble lsp_document_diagnostics", opts) -vim.api.nvim_set_keymap("n", "xl", "Trouble loclist", opts) -vim.api.nvim_set_keymap("n", "xq", "Trouble quickfix", opts) -vim.api.nvim_set_keymap("n", "gR", "Trouble lsp_references", opts) diff --git a/nvim/lua/plugins/web-devicons.lua b/nvim/lua/plugins/web-devicons.lua deleted file mode 100644 index bd948a3..0000000 --- a/nvim/lua/plugins/web-devicons.lua +++ /dev/null @@ -1,88 +0,0 @@ -local M = {} - -function M.init() - require("nvim-web-devicons").setup({ - override = { - html = { - icon = "", - color = "#DE8C92", - name = "html", - }, - css = { - icon = "", - color = "#61afef", - name = "css", - }, - js = { - icon = "", - color = "#EBCB8B", - name = "js", - }, - ts = { - color = "#519ABA", - name = "ts", - }, - rs = { - icon = "", - color = "#FFAA30", - name = "rs", - }, - kt = { - color = "#ffcb91", - name = "kt", - }, - png = { - icon = " ", - color = "#BD77DC", - name = "png", - }, - jpg = { - icon = " ", - color = "#BD77DC", - name = "jpg", - }, - jpeg = { - icon = " ", - color = "#BD77DC", - name = "jpeg", - }, - mp3 = { - icon = "", - color = "#C8CCD4", - name = "mp3", - }, - mp4 = { - icon = "", - color = "#C8CCD4", - name = "mp4", - }, - out = { - icon = "", - color = "#C8CCD4", - name = "out", - }, - toml = { - icon = "", - color = "#61afef", - name = "toml", - }, - lock = { - icon = "", - color = "#DE6B74", - name = "lock", - }, - zip = { - icon = "", - color = "#EBCB8B", - name = "zip", - }, - xz = { - icon = "", - color = "#EBCB8B", - name = "xz", - }, - }, - }) -end - -return M diff --git a/nvim/plugin/color.vim b/nvim/plugin/color.vim index 760a8b0..aee9ee1 100644 --- a/nvim/plugin/color.vim +++ b/nvim/plugin/color.vim @@ -9,3 +9,20 @@ hi! LspDiagnosticsLineNrHint guibg=#1E205D guifg=#008bbd gui=bold hi! TelescopeNormal guibg=#000000 highlight default link TelescopePromptPrefix TelescopeNormal highlight default link TelescopePromptCounter TelescopeNormal + +" gray +highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080 +" blue +highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6 +highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6 +" light blue +highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE +highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE +highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE +" pink +highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0 +highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0 +" front +highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4 +highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4 +highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4 diff --git a/pipe-viewer/pipe-viewer.conf b/pipe-viewer/pipe-viewer.conf index 23b3110..e24562c 100644 --- a/pipe-viewer/pipe-viewer.conf +++ b/pipe-viewer/pipe-viewer.conf @@ -1,11 +1,12 @@ #!/usr/bin/perl -# CLI Pipe Viewer 0.1.8 - configuration file +# CLI Pipe Viewer 0.2.0 - configuration file our $CONFIG = { api_host => "auto", auto_captions => 0, autoplay_mode => 0, + bypass_age_gate_with_proxy => 0, cache_dir => "/tmp/pipe-viewer", colors => 1, comments_order => "top", @@ -82,6 +83,7 @@ our $CONFIG = { split_videos => 1, srt_languages => ["en", "es"], subscribed_channels_file => "$ENV{HOME}/.config/pipe-viewer/subscribed_channels.txt", + subscriptions_lifetime => 600, subscriptions_limit => 10000, thousand_separator => ".", timeout => undef,