commit 1ede5f5311d3b34deaa0fc9b579ef4241d10adb3 Author: ksyasuda Date: Wed Nov 2 22:50:13 2022 -0700 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c49f2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +plugin +spell +.git +*.old diff --git a/autocommands.vim b/autocommands.vim new file mode 100644 index 0000000..f6a5895 --- /dev/null +++ b/autocommands.vim @@ -0,0 +1,10 @@ +" open at last location if possible +if has('autocmd') + au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +endif + +" open help and man pages in a vertical split +autocmd FileType help wincmd L +autocmd FileType man wincmd L +" make terminal not have line numbers +autocmd TermOpen * setlocal nonumber norelativenumber diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..a8f5c3d --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,50 @@ +{ + "diagnostic.displayByAle": false, + "diagnostic.enable": true, + "diagnostic.level": "hint", + "diagnostic-languageserver.enable": true, + "diagnostic-languageserver.filetypes": { + "sh": "shellcheck", + "python": "pylint" + }, + "diagnostic-languageserver.mergeConfig": true, + "diagnostic-languageserver.formatFiletypes": { + "sh": "shfmt", + "python": ["black", "isort"] + }, + "diagnostic-languageserver.formatters": { + "shfmt": { + "command": "shfmt", + "args": ["-i", "4", "-ci", "-sr"] + }, + "black": { + "command": "black" + } + }, + "pyright.organizeimports.provider": "isort", + "pyright.completion.importSupport": true, + "pyright.enable": true, + "python.linting.pylintEnabled": true, + "python.linting.pylintPath": "/usr/bin/pylint", + "python.formatting.blackPath": "/usr/bin/black", + "python.analysis.autoSearchPaths": true, + "python.venvPath": "env", + "languageserver": { + "python": { + "command": "pyright", + "filetypes": ["python", "py"] + } + }, + "hover.floatConfig": { + "border": true, + "shadow": true, + "focusable": true, + "highlight": "CocFloating", + "borderhighlight": "CocFloating" + }, + "diagnostic.virtualText": true, + "diagnostic.virtualTextLines": 5, + "diagnostic.virtualTextLevel": "information", + "codeLens.enable": true, + "codeLens.position": "eol" +} diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..50b6977 --- /dev/null +++ b/init.vim @@ -0,0 +1,98 @@ +if has('autocmd') + au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +endif + +" open help and man pages in a vertical split +autocmd FileType help wincmd L +autocmd FileType man wincmd L +" make terminal not have line numbers +autocmd TermOpen * setlocal nonumber norelativenumber + +" " " gray +" highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080 +" " blue +" highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6 +" highlight! link CmpItemAbbrMatchFuzzy CmpItemAbbrMatch +" " light blue +" highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE +" highlight! link CmpItemKindInterface CmpItemKindVariable +" highlight! link CmpItemKindText CmpItemKindVariable +" " pink +" highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0 +" highlight! link CmpItemKindMethod CmpItemKindFunction +" " front +" highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4 +" highlight! link CmpItemKindProperty CmpItemKindKeyword +" highlight! link CmpItemKindUnit CmpItemKindKeyword +" highlight! PmenuSel guibg=#51afef guifg=NONE +" highlight! Pmenu guifg=#C5CDD9 guibg=#51afef + +lua require('settings') +lua require('plugins') +source ~/.config/nvim/keybindings.vim + +" nvim plugins +source ~/.config/nvim/plugin-confs/bufferline.lua +" source ~/.config/nvim/plugin-confs/dashboard-art.vim +source ~/.config/nvim/plugin-confs/dashboard-nvim.lua +source ~/.config/nvim/plugin-confs/gitsigns.lua +source ~/.config/nvim/plugin-confs/lspfuzzy.lua +source ~/.config/nvim/plugin-confs/lualine.lua +source ~/.config/nvim/plugin-confs/nvimtree.lua +source ~/.config/nvim/plugin-confs/presence.lua +source ~/.config/nvim/plugin-confs/treesitter.lua +source ~/.config/nvim/plugin-confs/whichkey.lua +source ~/.config/nvim/plugin-confs/telescope.lua + +source ~/.config/nvim/plugin-confs/code_actions.lua +source ~/.config/nvim/plugin-confs/goto-preview.lua +source ~/.config/nvim/plugin-confs/lsp-kind.lua +source ~/.config/nvim/plugin-confs/lspconfig.lua +source ~/.config/nvim/plugin-confs/lsplines.lua +source ~/.config/nvim/plugin-confs/null-ls.lua +source ~/.config/nvim/plugin-confs/nvim-cmp.lua +source ~/.config/nvim/plugin-confs/fidget.lua +source ~/.config/nvim/plugin-confs/symbols-outline.lua +" source ~/.config/nvim/plugin-confs/copilot.lua +" source ~/.config/nvim/plugin-confs/lsp-signature.lua +" source ~/.config/nvim/plugin-confs/nvim-docs-view.lua + +" nvim and vim plugins +source ~/.vim/plugin-confs/floaterm.vim +source ~/.vim/plugin-confs/fzf.vim +source ~/.vim/plugin-confs/vim-closetag.vim +source ~/.vim/plugin-confs/wakatime.vim + +source ~/.config/nvim/plugin-confs/doomone.lua +source ~/.config/nvim/plugin-confs/dracula.lua +source ~/.config/nvim/plugin-confs/github-theme.lua +source ~/.config/nvim/plugin-confs/onedarkpro.lua + +source ~/.config/nvim/lua/toggle_lsp_diagnostics.lua + +" CUSTOM COMMANDS +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), 0) + +command! -bang -nargs=? -complete=dir AllFiles + \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore', 'options': ['--layout=reverse', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), 0)) + +command! -bang -nargs=? -complete=dir Lines + \ call fzf#vim#lines(, ({'options': ['--layout=reverse']}), 0) + +command! -bang -nargs=? -complete=dir Buffers + \ call fzf#vim#buffers(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), 0) + +command! Reload execute "source ~/.config/nvim/init.vim" +command! Config execute ":e ~/.config/nvim/init.vim" +command! Plugins execute ":e ~/.config/nvim/lua/plugins.lua" +command! Settings execute ":e ~/.config/nvim/lua/settings.lua" +command! Env execute ":Dotenv .env" +command! MakeTags !ctags -R . +command! Ovewrite execute ":w !sudo tee %" +command! Aniwrapper execute ":FloatermNew aniwrapper -qtdoomone -D 144" + +set termguicolors +" colorscheme doom-one +colorscheme onedarkpro +" colorscheme github_dark diff --git a/keybindings.vim b/keybindings.vim new file mode 100644 index 0000000..9fa6c5b --- /dev/null +++ b/keybindings.vim @@ -0,0 +1,140 @@ +nmap :set paste!set paste? +nmap :! + +" reselect visual selection after indent +vnoremap < >gv + +" for toggling/hiding the split-term +tnoremap :FloatermToggle floatterm +tnoremap +tnoremap tt :FloatermToggle split-term +tnoremap tf :FloatermToggle floatterm +tnoremap tp :FloatermToggle ipython +tnoremap tP :FloatermToggle ipython-full + +nmap :bnext +nmap :bprev +nmap :wa:FloatermToggle floatterm + +" open file under cursor, create if necessary +nnoremap // :Telescope current_buffer_fuzzy_find +nnoremap ?? :BLines + +nmap gA :lua vim.lsp.buf.code_actions() +nmap gd :Telescope lsp_definitions +nmap gDc :Telescope lsp_implementations +nmap gDf :Telescope lsp_definitions +nmap gF :edit +nmap gT :Telescope lsp_type_definitions +nmap gb :Gitsigns blame_line +" nmap gd :lua vim.lsp.buf.definition() +nmap gi :Telescope lsp_implementations +nmap gj :Telescope jumplist +nmap gl :lua vim.lsp.buf.code_lens() +nmap gr :Telescope lsp_references +nmap gs :lua vim.lsp.buf.signature_help() + +nmap Q !!$SHELL + +nmap rn :lua vim.lsp.buf.rename() + +nmap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 +nmap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 + +nmap bb :Telescope buffers +nmap bk :bdelete +nmap bn :bnext +nmap bp :bprev + +nmap ca :lua vim.lsp.buf.code_action() +nmap cc :vert Copilot +nmap cd :Telescope diagnostics +" nmap cl :lua vim.lsp.diagnostic.show_line_diagnostics() +nnoremap cn :DashboardNewFile + +nnoremap ff :Telescope find_files +nnoremap fg :Telescope live_grep +nnoremap fb :Telescope buffers +nnoremap fh :Telescope help_tags +nmap fa :DashboardFindWord +nmap fb :DashboardJumpMark +nmap fh :DashboardFindHistory + +nmap gb :Gitsigns blame_line +nmap gc :Telescope git_commits +nmap gf :Telescope git_files +" nmap gg :Neogit +nmap gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit +nnoremap gP lua require('goto-preview').close_all_win() +nnoremap gR Telescope lsp_references +nnoremap gpc lua require('goto-preview').close_all_win() +nnoremap gpd lua require('goto-preview').goto_preview_definition() +nnoremap gpi lua require('goto-preview').goto_preview_implementation() + +nmap hc :Telescope commands +nmap hh :Telescope tags +nmap hk :Telescope keymaps +nmap hs :Telescope spell_suggest + +nmap isp :-1read $HOME/Templates/python.py4jw + +nmap j :AnyJump + +" nmap K :DocsViewToggle +nmap K :lua vim.lsp.buf.hover() + +nmap ld :Telescope lsp_definitions +nmap la :lua vim.lsp.buf.code_action() +nmap lci :Telescope lsp_incoming_calls +nmap lco :Telescope lsp_outgoing_calls +nmap lh :lua vim.lsp.buf.signature_help() +nmap li :Telescope lsp_implementations +nmap lr :Telescope lsp_references +nmap lR :lua vim.lsp.buf.rename() +nmap ls :Telescope lsp_document_symbols +nmap lt :Telescope lsp_type_definitions +nmap lw :Telescope lsp_dynamic_workspace_symbols + +nmap n :NvimTreeToggle + +nmap ob :FloatermNew --title=bpytop --opener=vsplit bpytop +nmap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker +nmap of :wa:FloatermToggle floatterm +nmap oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45 +nmap on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp +nmap op :FloatermNew --title=ipython --name=ipython --opener=split --wintype=vsplit --position=botright --width=0.5 ipython +nmap oP :FloatermNew --title=ipython-full --name=ipython-full --opener=edit --width=1.0 --height=1.0 ipython +nmap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" +nmap ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5 + +nmap r :NvimTreeRefresh + +nmap sl :SessionLoad +nmap ss :SessionSave +nmap sc :nohls +nmap sC :Telescope commands +nmap sf :Telescope find_files +nmap sh :Telescope command_history +nmap sm :Telescope man_pages +nmap s/ :Telescope search_history + +nnoremap tc :Telescope colorscheme +nmap tf :wa:FloatermToggle floatterm +nmap to :SymbolsOutline +nmap tp :FloatermToggle ipython +nmap tP :FloatermToggle ipython-full +nmap tt :FloatermToggle split-term + +nmap wa :lua vim.lsp.buf.add_workspace_folder() +nmap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) +nmap wr :lua vim.lsp.buf.remove_workspace_folder() + +" nnoremap xd TroubleToggle document_diagnostics +" nnoremap xl TroubleToggle loclist +" nnoremap xq TroubleToggle quickfix +" nnoremap xw TroubleToggle workspace_diagnostics +" nnoremap xx TroubleToggle + +nmap y "+ +vmap y "+ diff --git a/lua/keybindings.lua b/lua/keybindings.lua new file mode 100644 index 0000000..dbae50f --- /dev/null +++ b/lua/keybindings.lua @@ -0,0 +1,3 @@ +local function map(m, k, v) + vim.keymap.set(m, k, v, {silent = true, noremap = true}) +end diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..75091e3 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,207 @@ +vim.cmd [[packadd packer.nvim]] +require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + use 'nvim-lua/plenary.nvim' + use { + 'nvim-treesitter/nvim-treesitter', + run = function() require('nvim-treesitter.install').update({ with_sync = true }) end, + } + + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } + + + use { + "zbirenbaum/copilot.lua", + after = "lualine.nvim", + config = function () + vim.defer_fn(function() + require('copilot').setup({ + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = "[[", + jump_next = "]]", + accept = "", + refresh = "gr", + open = "" + }, + }, + suggestion = { + enabled = true, + auto_trigger = true, + debounce = 75, + keymap = { + accept = "", + next = "", + prev = "", + dismiss = "", + }, + }, + -- filetypes = { + -- yaml = false, + -- markdown = false, + -- help = false, + -- gitcommit = false, + -- gitrebase = false, + -- hgcommit = false, + -- svn = false, + -- cvs = false, + -- ["."] = false, + -- }, + copilot_node_command = 'node', -- Node version must be < 18 + plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", + server_opts_overrides = {}, + }) + end, 100) + end, + } + + use { + "zbirenbaum/copilot-cmp", + after = { "copilot.lua" }, + config = function () + require("copilot_cmp").setup({ + -- method = "getCompletionsCycling", + -- formatters = { + -- insert_text = require("copilot_cmp.format").remove_existing + -- } + }) + end + } + + use { + 'junegunn/fzf', + run = function() vim.fn['fzf#install']() end + } + + use { + "lewis6991/hover.nvim", + config = function() + require("hover").setup { + init = function() + -- Require providers + require("hover.providers.lsp") + -- require('hover.providers.gh') + -- require('hover.providers.jira') + require('hover.providers.man') + require('hover.providers.dictionary') + end, + preview_opts = { + border = "rounded" + -- border = { + -- { "╭", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "╮", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- { "╯", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "╰", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- } + }, + -- Whether the contents of a currently open hover window should be moved + -- to a :h preview-window when pressing the hover keymap. + preview_window = false, + title = true + } + + -- Setup keymaps + vim.keymap.set("n", "K", require("hover").hover, {desc = "hover.nvim"}) + vim.keymap.set("n", "gK", require("hover").hover_select, {desc = "hover.nvim (select)"}) + end + } + + use 'ap/vim-css-color' + use 'jiangmiao/auto-pairs' + use 'junegunn/fzf.vim' + use 'pechorin/any-jump.vim' + use 'tpope/vim-commentary' + use 'tpope/vim-surround' + use 'voldikss/vim-floaterm' + use 'wakatime/vim-wakatime' + + use { + 'akinsho/nvim-bufferline.lua' + } + use { + 'andweeb/presence.nvim' + } + use { + 'folke/which-key.nvim' + } + use { + 'glepnir/dashboard-nvim' + } + use { + 'kyazdani42/nvim-tree.lua' + } + use 'kyazdani42/nvim-web-devicons' + use { + 'lewis6991/gitsigns.nvim' + } + use { + 'nvim-telescope/telescope.nvim' + } + use { + 'ojroques/nvim-lspfuzzy' + } + + use 'L3MON4D3/LuaSnip' + -- use 'amrbashir/nvim-docs-view' + use { + 'hrsh7th/nvim-cmp' + } + use { + 'hrsh7th/cmp-nvim-lsp' + } + use { + 'hrsh7th/cmp-nvim-lua' + } + use { + 'hrsh7th/cmp-nvim-lsp-signature-help' + } + use { + 'hrsh7th/cmp-path' + } + use { + 'hrsh7th/cmp-buffer' + } + use { + 'j-hui/fidget.nvim' + } + use { + 'jose-elias-alvarez/null-ls.nvim' + } + use { + 'ksyasuda/lsp_lines.nvim' + } + use { + 'neovim/nvim-lspconfig' + } + use { + 'onsails/lspkind-nvim' + } + -- use 'ray-x/lsp_signature.nvim' + use { + 'rmagatti/goto-preview' + } + use 'saadparwaiz1/cmp_luasnip' + use 'williamboman/nvim-lsp-installer' + + use { + 'Mofiqul/dracula.nvim' + } + use { + 'NTBBloodbath/doom-one.nvim' + } + use { + 'olimorris/onedarkpro.nvim' + } + use { + 'projekt0n/github-nvim-theme' + } +end) diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 0000000..b7ae5a6 --- /dev/null +++ b/lua/settings.lua @@ -0,0 +1,43 @@ +local g = vim.g +local o = vim.o +local A = vim.api + +g.mapleader = " " +g.maplocalleader = ',' +g.fzf_command = 'fzf --height 90% --width=85% --layout=reverse --preview "bat --color=always {}"' +o.completeopt="menu,menuone,noselect" +o.showmode = false +o.termguicolors = true +o.background = 'dark' +o.mouse = 'a' +o.syntax = 'on' +o.laststatus = 3 +o.number = true +o.relativenumber = true +o.colorcolumn = '80' +o.textwidth = 80 +o.shiftwidth = 4 +o.tabstop = 4 +o.autoindent = true +o.ignorecase = true +o.smartcase = true +o.incsearch = true +o.hlsearch = true +o.title = true +o.splitright = true +o.cursorline = true +o.scrolloff = 8 +o.sidescrolloff = 8 +o.wildmenu = true +o.wildignore= '.git,.hg,.svn,CVS,.DS_Store,.idea,.vscode,.vscode-test,node_modules' +o.showmatch = true +o.list = true +o.listchars = 'tab:»·,trail:·,nbsp:·,extends:>,precedes:<' +o.encoding = 'utf-8' +o.guifont = 'JetBrainsMono Nerd Font 14' +o.expandtab = true +o.hidden = true +o.cmdheight = 1 +o.updatetime = 300 +o.timeoutlen = 500 +o.pumwidth=35 diff --git a/lua/toggle_lsp_diagnostics.lua b/lua/toggle_lsp_diagnostics.lua new file mode 100644 index 0000000..4c042c4 --- /dev/null +++ b/lua/toggle_lsp_diagnostics.lua @@ -0,0 +1,11 @@ +local diagnostics_active = true +local toggle_diagnostics = function() + diagnostics_active = not diagnostics_active + if diagnostics_active then + vim.diagnostic.show() + else + vim.diagnostic.hide() + end +end + +vim.keymap.set('n', 'td', toggle_diagnostics) diff --git a/plugin-confs/bufferline.lua b/plugin-confs/bufferline.lua new file mode 100644 index 0000000..6f029cd --- /dev/null +++ b/plugin-confs/bufferline.lua @@ -0,0 +1,85 @@ +require('bufferline').setup { + options = { + -- numbers = function(opts) + -- return string.format("%s", opts.id) + -- end, + numbers = function(opts) + return "" + end, + -- number_style = "superscript" | "subscript" | "" | { "none", "subscript" }, -- buffer_id at index 1, ordinal at index 2 + -- number_style = "none", + close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + -- NOTE: this plugin is designed with this icon in mind, + -- and so changing this is NOT recommended, this is intended + -- as an escape hatch for people who cannot bear it for whatever reason + indicator_style = '▎', + buffer_close_icon = '', + modified_icon = '●', + close_icon = '', + left_trunc_marker = '', + right_trunc_marker = '', + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- remove extension from markdown files for example + if buf.name:match('%.md') then + return vim.fn.fnamemodify(buf.name, ':t:r') + end + end, + max_name_length = 18, + max_prefix_length = 15, -- prefix used when a buffer is de-duplicated + tab_size = 18, + -- diagnostics = false | "nvim_lsp" | "coc", + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = false, + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local s = " " + for e, n in pairs(diagnostics_dict) do + local sym = e == "error" and " " + or e == "hint" and " " + or (e == "warning" and " " or "" ) + s = s .. n .. sym + end + return s + end, + custom_filter = function(buf_number, buf_numbers) + -- filter out filetypes you don't want to see + if vim.bo[buf_number].filetype ~= "" then + return true + end + -- filter out by buffer name + if vim.fn.bufname(buf_number) ~= "" then + return true + end + -- filter out based on arbitrary rules + -- e.g. filter out vim wiki buffer from tabline in your work repo + if vim.fn.getcwd() == "" and vim.bo[buf_number].filetype ~= "wiki" then + return true + end + -- filter out by it's index number in list (don't show first buffer) + if buf_numbers[1] ~= buf_number then + return true + end + end, + -- offsets = {{filetype = "NvimTree", text = "File Explorer" | function , text_align = "left" | "center" | "right"}}, + -- offsets = text_align = "left" | "center" | "right"}}, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = false, + show_tab_indicators = true, + persist_buffer_sort = false, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + -- separator_style = "slant" | "thick" | "thin" | { 'any', 'any' }, + separator_style = "thick", + enforce_regular_tabs = false, + always_show_bufferline = true, + -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) + sort_by = 'id', + } +} diff --git a/plugin-confs/code_actions.lua b/plugin-confs/code_actions.lua new file mode 100644 index 0000000..1d24ff5 --- /dev/null +++ b/plugin-confs/code_actions.lua @@ -0,0 +1,14 @@ +local M = {} + +local lsp_util = vim.lsp.util + +function M.code_action_listener() + local context = { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() } + local params = lsp_util.make_range_params() + params.context = context + vim.lsp.buf_request(0, 'textDocument/codeAction', params, function(err, _, result) + -- do something with result - e.g. check if empty and show some indication such as a sign + end) +end + +return M diff --git a/plugin-confs/copilot.lua b/plugin-confs/copilot.lua new file mode 100644 index 0000000..39b057a --- /dev/null +++ b/plugin-confs/copilot.lua @@ -0,0 +1,38 @@ +require('copilot').setup({ + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = "[[", + jump_next = "]]", + accept = "", + refresh = "gr", + open = "" + }, + }, + suggestion = { + enabled = true, + auto_trigger = false, + debounce = 75, + keymap = { + accept = "", + next = "", + prev = "", + dismiss = "", + }, + }, + filetypes = { + yaml = false, + markdown = false, + help = false, + gitcommit = false, + gitrebase = false, + hgcommit = false, + svn = false, + cvs = false, + ["."] = false, + }, + copilot_node_command = 'node', -- Node version must be < 18 + plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", + server_opts_overrides = {}, +}) diff --git a/plugin-confs/dashboard-art.vim b/plugin-confs/dashboard-art.vim new file mode 100644 index 0000000..4cdd9bb --- /dev/null +++ b/plugin-confs/dashboard-art.vim @@ -0,0 +1,8 @@ +let g:dashboard_custom_header = [ +\ ' ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗', +\ ' ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║', +\ ' ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║', +\ ' ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║', +\ ' ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║', +\ ' ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝', +\] diff --git a/plugin-confs/dashboard-nvim.lua b/plugin-confs/dashboard-nvim.lua new file mode 100644 index 0000000..90ecb4d --- /dev/null +++ b/plugin-confs/dashboard-nvim.lua @@ -0,0 +1,36 @@ +local home = os.getenv('HOME') +local db = require('dashboard') +-- macos +-- db.preview_command = 'cat | lolcat -F 0.3' +-- linux +-- db.preview_command = 'ueberzug' +-- db.preview_file_path = home .. '/.config/nvim/static/neovim.cat' +-- db.preview_file_height = 11 +-- db.preview_file_width = 70 +vim.cmd('source $HOME/.config/nvim/static/nvim-dashboard.vim') +db.custom_center = { + {icon = ' ', + desc = 'Recently latest session ', + shortcut = 'SPC s l', + action ='SessionLoad'}, + {icon = ' ', + desc = 'Recently opened files ', + action = 'DashboardFindHistory', + shortcut = 'SPC f h'}, + {icon = ' ', + desc = 'Find File ', + action = 'Telescope find_files find_command=rg,--hidden,--files', + shortcut = 'SPC f f'}, + {icon = ' ', + desc ='File Browser ', + action = 'NvimTreeToggle', + shortcut = 'SPC f b'}, + {icon = ' ', + desc = 'Find word ', + action = 'Telescope live_grep', + shortcut = 'SPC f w'}, + {icon = ' ', + desc = 'Open Personal dotfiles ', + action = ':e ~/.config/nvim/init.vim', + shortcut = 'SPC f d'}, +} diff --git a/plugin-confs/doomone.lua b/plugin-confs/doomone.lua new file mode 100644 index 0000000..0e11b3e --- /dev/null +++ b/plugin-confs/doomone.lua @@ -0,0 +1,57 @@ +-- require('doom-one').setup({ +-- cursor_coloring = false, +-- terminal_colors = false, +-- italic_comments = false, +-- enable_treesitter = true, +-- transparent_background = false, +-- pumblend = { +-- enable = true, +-- transparency_amount = 20, +-- }, +-- plugins_integrations = { +-- neorg = true, +-- barbar = true, +-- bufferline = false, +-- gitgutter = false, +-- gitsigns = true, +-- telescope = false, +-- neogit = true, +-- nvim_tree = true, +-- dashboard = true, +-- startify = true, +-- whichkey = true, +-- indent_blankline = true, +-- vim_illuminate = true, +-- lspsaga = false, +-- }, +-- }) + + +vim.g.doom_one_cursor_coloring = true +-- Set :terminal colors +vim.g.doom_one_terminal_colors = true +-- Enable italic comments +vim.g.doom_one_italic_comments = false +-- Enable TS support +vim.g.doom_one_enable_treesitter = true +-- Color whole diagnostic text or only underline +vim.g.doom_one_diagnostics_text_color = true +-- Enable transparent background +vim.g.doom_one_transparent_background = false + +-- Pumblend transparency +vim.g.doom_one_pumblend_enable = false +vim.g.doom_one_pumblend_transparency = 20 + +-- Plugins integration +vim.g.doom_one_plugin_neorg = true +vim.g.doom_one_plugin_barbar = false +vim.g.doom_one_plugin_telescope = false +vim.g.doom_one_plugin_neogit = true +vim.g.doom_one_plugin_nvim_tree = true +vim.g.doom_one_plugin_dashboard = true +vim.g.doom_one_plugin_startify = true +vim.g.doom_one_plugin_whichkey = true +vim.g.doom_one_plugin_indent_blankline = true +vim.g.doom_one_plugin_vim_illuminate = true +vim.g.doom_one_plugin_lspsaga = false diff --git a/plugin-confs/dracula.lua b/plugin-confs/dracula.lua new file mode 100644 index 0000000..e871520 --- /dev/null +++ b/plugin-confs/dracula.lua @@ -0,0 +1,33 @@ +-- customize dracula color palette +vim.g.dracula_colors = { + bg = "#282A36", + fg = "#F8F8F2", + selection = "#44475A", + comment = "#6272A4", + red = "#FF5555", + orange = "#FFB86C", + yellow = "#F1FA8C", + green = "#50fa7b", + purple = "#BD93F9", + cyan = "#8BE9FD", + pink = "#FF79C6", + bright_red = "#FF6E6E", + bright_green = "#69FF94", + bright_yellow = "#FFFFA5", + bright_blue = "#D6ACFF", + bright_magenta = "#FF92DF", + bright_cyan = "#A4FFFF", + bright_white = "#FFFFFF", + menu = "#21222C", + visual = "#3E4452", + gutter_fg = "#4B5263", + nontext = "#3B4048", +} +-- show the '~' characters after the end of buffers +vim.g.dracula_show_end_of_buffer = true +-- use transparent background +vim.g.dracula_transparent_bg = true +-- set custom lualine background color +vim.g.dracula_lualine_bg_color = "#44475a" +-- set italic comment +vim.g.dracula_italic_comment = true diff --git a/plugin-confs/fidget.lua b/plugin-confs/fidget.lua new file mode 100644 index 0000000..0000313 --- /dev/null +++ b/plugin-confs/fidget.lua @@ -0,0 +1,49 @@ +require"fidget".setup { + text = { + spinner = "pipe", -- animation shown when tasks are ongoing + done = "✔", -- character shown when all tasks are complete + commenced = "Started", -- message shown when task starts + completed = "Completed", -- message shown when task completes + }, + align = { + bottom = true, -- align fidgets along bottom edge of buffer + right = true, -- align fidgets along right edge of buffer + }, + timer = { + spinner_rate = 125, -- frame rate of spinner animation, in ms + fidget_decay = 2000, -- how long to keep around empty fidget, in ms + task_decay = 1000, -- how long to keep around completed task, in ms + }, + window = { + relative = "win", -- where to anchor, either "win" or "editor" + blend = 100, -- &winblend for the window + zindex = nil, -- the zindex value for the window + }, + fmt = { + leftpad = true, -- right-justify text in fidget box + stack_upwards = true, -- list of tasks grows upwards + max_width = 0, -- maximum width of the fidget box + fidget = -- function to format fidget title + function(fidget_name, spinner) + return string.format("%s %s", spinner, fidget_name) + end, + task = -- function to format each task line + function(task_name, message, percentage) + return string.format( + "%s%s [%s]", + message, + percentage and string.format(" (%s%%)", percentage) or "", + task_name + ) + end, + }, + -- sources = { + -- * = { + -- ignore = false, + -- }, + -- }, + -- debug = { + -- logging = false, -- whether to enable logging, for debugging + -- strict = false, -- whether to interpret LSP strictly + -- }, +} diff --git a/plugin-confs/git-blame.lua b/plugin-confs/git-blame.lua new file mode 100644 index 0000000..8bdf974 --- /dev/null +++ b/plugin-confs/git-blame.lua @@ -0,0 +1,2 @@ +vim.g.gitblame_highlight_group = "Question" +vim.g.gitblame_enabled = 0 diff --git a/plugin-confs/github-theme.lua b/plugin-confs/github-theme.lua new file mode 100644 index 0000000..6e96828 --- /dev/null +++ b/plugin-confs/github-theme.lua @@ -0,0 +1,19 @@ +-- Example config in Lua +require("github-theme").setup({ + theme_style = "dark", + function_style = "italic", + sidebars = {"qf", "vista_kind", "terminal", "packer"}, + + -- Change the "hint" color to the "orange" color, and make the "error" color bright red + colors = {hint = "orange", error = "#ff0000"}, + + -- Overwrite the highlight groups + overrides = function(c) + return { + htmlTag = {fg = c.red, bg = "#282c34", sp = c.hint, style = "underline"}, + DiagnosticHint = {link = "LspDiagnosticsDefaultHint"}, + -- this will remove the highlight groups + TSField = {}, + } + end +}) diff --git a/plugin-confs/gitsigns.lua b/plugin-confs/gitsigns.lua new file mode 100644 index 0000000..35ad93e --- /dev/null +++ b/plugin-confs/gitsigns.lua @@ -0,0 +1,43 @@ +require('gitsigns').setup { + signs = { + add = {hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, + change = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + topdelete = {hl = 'GitSignsDelete', text = '‾', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter_opts = { + relative_time = false + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + yadm = { + enable = false + }, +} diff --git a/plugin-confs/goto-preview.lua b/plugin-confs/goto-preview.lua new file mode 100644 index 0000000..8309252 --- /dev/null +++ b/plugin-confs/goto-preview.lua @@ -0,0 +1,19 @@ +require('goto-preview').setup { + width = 120; -- Width of the floating window + height = 20; -- Height of the floating window + border = {"╭", "─" ,"╮", "│", "╯", "─", "╰", "│"}; -- Border characters of the floating window + -- border = {"┌", "─" ,"┐", "│", "┘", "─", "└", "│"}; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = 25; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + -- telescope = telescope.themes.get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = false, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden +} diff --git a/plugin-confs/lsp-kind.lua b/plugin-confs/lsp-kind.lua new file mode 100644 index 0000000..b34ed20 --- /dev/null +++ b/plugin-confs/lsp-kind.lua @@ -0,0 +1,8 @@ +-- lspkind.lua +local lspkind = require("lspkind") +lspkind.init({ + symbol_map = { + Copilot = "" + }, +}) +vim.api.nvim_set_hl(0, "CmpItemKindCopilot", {fg ="#6CC644"}) diff --git a/plugin-confs/lsp-signature.lua b/plugin-confs/lsp-signature.lua new file mode 100644 index 0000000..899f9e7 --- /dev/null +++ b/plugin-confs/lsp-signature.lua @@ -0,0 +1,54 @@ +cfg = { + debug = false, -- set to true to enable debug logging + log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on + -- default is ~/.cache/nvim/lsp_signature.log + verbose = false, -- show debug line number + + bind = true, -- This is mandatory, otherwise border config won't get registered. + -- If you want to hook lspsaga or other signature handler, pls set to false + doc_lines = 12, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated); + -- set to 0 if you DO NOT want any API comments be shown + -- This setting only take effect in insert mode, it does not affect signature help in normal + -- mode, 10 by default + + floating_window = true, -- show hint in a floating window, set to false for virtual text only mode + floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note: + -- will set to true when fully tested, set to false will use whichever side has more space + -- this setting will be helpful if you do not want the PUM and floating win overlap + + floating_window_off_x = 1, -- adjust float windows x position. + floating_window_off_y = -1, -- adjust float windows y position. + + fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters + hint_enable = true, -- virtual hint enable + hint_prefix = " ", -- Panda for parameter + hint_scheme = "String", + hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight + max_height = 15, -- max height of signature floating_window, if content is more than max_height, you can scroll down + -- to view the hiding contents + max_width = 85, -- max_width of signature floating_window, line will be wrapped if exceed max_width + handler_opts = { + border = "rounded" -- double, rounded, single, shadow, none + }, + + always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58 + + auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil. + extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} + zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom + + padding = '', -- character to pad on left and right of signature can be ' ', or '|' etc + + transparency = nil, -- disabled by default, allow floating win transparent value 1~100 + shadow_blend = 36, -- if you using shadow as border use this set the opacity + shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' + timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency + toggle_key = nil -- toggle signature on and off in insert mode, e.g. toggle_key = '' +} + +-- recommended: +require 'lsp_signature'.setup(cfg) -- no need to specify bufnr if you don't use toggle_key + +-- You can also do this inside lsp on_attach +-- note: on_attach deprecated +-- require'lsp_signature'.on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key diff --git a/plugin-confs/lspconfig.lua b/plugin-confs/lspconfig.lua new file mode 100644 index 0000000..14cb9bd --- /dev/null +++ b/plugin-confs/lspconfig.lua @@ -0,0 +1,217 @@ +local opts = { noremap = true, silent = true } +vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) +vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) +vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) +vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + -- set in ~/.config/nvim/keybindings.vim + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) + -- highlighting things under cursor + -- if client.resolved_capabilities.document_highlight then + -- vim.cmd [[ + -- hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow + -- hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow + -- hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow + -- augroup lsp_document_highlight + -- autocmd! * + -- autocmd! CursorHold lua vim.lsp.buf.document_highlight() + -- autocmd! CursorMoved lua vim.lsp.buf.clear_references() + -- augroup END + -- ]] + -- end +end + +vim.cmd [[autocmd! ColorScheme * highlight NormalFloat guibg=#1f2335]] +vim.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]] + +-- squared corners + +-- local border = { +-- {"┌", "FloatBorder"}, +-- {"─", "FloatBorder"}, +-- {"┐", "FloatBorder"}, +-- {"|", "FloatBorder"}, +-- {"┘", "FloatBorder"}, +-- {"─", "FloatBorder"}, +-- {"└", "FloatBorder"}, +-- {"|", "FloatBorder"}, +-- } + +-- rounded + +local border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, +} + + +local handlers = { + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }), +} + +-- local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview +-- function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) +-- opts = { +-- { "border", border }, +-- } +-- opts.border = opts.border or border +-- return orig_util_open_floating_preview(contents, syntax, opts, ...) +-- end + +local DEFAULT_SETTINGS = { + ui = { + icons = { + -- The list icon to use for installed servers. + server_installed = "◍", + -- The list icon to use for servers that are pending installation. + server_pending = "◍", + -- The list icon to use for servers that are not installed. + server_uninstalled = "◍", + }, + keymaps = { + -- Keymap to expand a server in the UI + toggle_server_expand = "", + -- Keymap to install a server + install_server = "i", + -- Keymap to reinstall/update a server + update_server = "u", + -- Keymap to update all installed servers + update_all_servers = "U", + -- Keymap to uninstall a server + uninstall_server = "X", + }, + }, + + -- The directory in which to install all servers. + -- install_root_dir = "/home/sudacode/.vim/lsp", + + pip = { + -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior + -- and is not recommended. + -- + -- Example: { "--proxy", "https://proxyserver" } + install_args = {}, + }, + on_attach = on_attach, + handlers = handlers, + + -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when + -- debugging issues with server installations. + log_level = vim.log.levels.INFO, + + -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further + -- servers that are requested to be installed will be put in a queue. + max_concurrent_installers = 4, +} + +vim.diagnostic.config({ + virtual_text = true, + signs = true, + underline = false, + update_in_insert = false, + severity_sort = true, +}) + +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 = hl }) +end + +function PrintDiagnostics(opts, bufnr, line_nr, client_id) + bufnr = bufnr or 0 + line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) + opts = opts or { ['lnum'] = line_nr } + + local line_diagnostics = vim.diagnostic.get(bufnr, opts) + if vim.tbl_isempty(line_diagnostics) then return end + + local diagnostic_message = "" + for i, diagnostic in ipairs(line_diagnostics) do + diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") + print(diagnostic_message) + if i ~= #line_diagnostics then + diagnostic_message = diagnostic_message .. "\n" + end + end + vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) +end + +-- vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]] + +local lsp_installer = require("nvim-lsp-installer") + +-- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished +-- or if the server is already installed). +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + -- This setup() function will take the provided server configuration and decorate it with the necessary properties + -- before passing it onwards to lspconfig. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(DEFAULT_SETTINGS) +end) + + +-- local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' } +-- for _, lsp in pairs(servers) do +-- require('lspconfig')[lsp].setup { +-- on_attach = on_attach, +-- handlers = handlers, +-- flags = { +-- -- This will be the default in neovim 0.7+ +-- debounce_text_changes = 150, +-- } +-- } +-- end + +-- local plugins_path = vim.fn.stdpath("data") .. "site/autoload/plug.vim" +-- local dir_list = vim.fn.glob(plugins_path .. "/*", true, true) +-- local library_table = {} +-- for _, v in ipairs(dir_list) do +-- library_table[v .. "/lua"] = true +-- end +-- library_table[vim.fn.expand("$VIMRUNTIME/lua")] = true +-- library_table[vim.fn.stdpath("config") .. "/lua"] = true +-- require('lspconfig').sumneko_lua.setup({ +-- settings = { +-- Lua = { +-- diagnostics = { globals = { "vim" } }, +-- workspace = { library = library_table }, +-- }, +-- }, +-- }) + +-- -- require 'lspconfig'.bashls.setup {} diff --git a/plugin-confs/lspfuzzy.lua b/plugin-confs/lspfuzzy.lua new file mode 100644 index 0000000..a80ac36 --- /dev/null +++ b/plugin-confs/lspfuzzy.lua @@ -0,0 +1,16 @@ +require('lspfuzzy').setup { + methods = 'all', -- either 'all' or a list of LSP methods (see below) + jump_one = true, -- jump immediately if there is only one location + save_last = false, -- save last location results for the :LspFuzzyLast command + callback = nil, -- callback called after jumping to a location + fzf_preview = { -- arguments to the FZF '--preview-window' option + 'right:+{2}-/2' -- preview on the right and centered on entry + }, + fzf_action = { -- FZF actions + ['ctrl-t'] = 'tab split', -- go to location in a new tab + ['ctrl-v'] = 'vsplit', -- go to location in a vertical split + ['ctrl-x'] = 'split', -- go to location in a horizontal split + }, + fzf_modifier = ':~:.', -- format FZF entries, see |filename-modifiers| + fzf_trim = false, -- trim FZF entries +} diff --git a/plugin-confs/lsplines.lua b/plugin-confs/lsplines.lua new file mode 100644 index 0000000..ffa8a09 --- /dev/null +++ b/plugin-confs/lsplines.lua @@ -0,0 +1,5 @@ +require("lsp_lines").setup() +-- Disable virtual_text since it's redundant due to lsp_lines. +vim.diagnostic.config({ + virtual_text = false, +}) diff --git a/plugin-confs/lualine.lua b/plugin-confs/lualine.lua new file mode 100644 index 0000000..5b22f12 --- /dev/null +++ b/plugin-confs/lualine.lua @@ -0,0 +1,52 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'codedark', + -- theme = 'dracula', + -- theme = 'horizon', + -- theme = 'onedark', + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff' }, + lualine_c = { 'filename' }, + lualine_x = { + { + 'diagnostics', + 'fileformat', + symbols = { + unix = '', -- e712 + dos = '', -- e70f + mac = '', -- e711 + } + }, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + 'filename', + file_status = true, -- Displays file status (readonly status, modified status) + path = 0, -- 0: Just the filename + shorting_target = 40, -- Shortens path to leave 40 spaces in the window + symbols = { + modified = '[+]', -- Text to show when the file is modified. + readonly = '[-]', -- Text to show when the file is non-modifiable or readonly. + unnamed = '[No Name]', -- Text to show for unnamed buffers. + } + }, + }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = { 'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive' } +} diff --git a/plugin-confs/neogit.lua b/plugin-confs/neogit.lua new file mode 100644 index 0000000..d7e0e0e --- /dev/null +++ b/plugin-confs/neogit.lua @@ -0,0 +1,73 @@ +local neogit = require("neogit") + +neogit.setup { + disable_signs = false, + disable_hint = false, + disable_context_highlighting = false, + disable_commit_confirmation = false, + auto_refresh = true, + disable_builtin_notifications = false, + use_magit_keybindings = false, + commit_popup = { + kind = "split", + }, + -- Change the default way of opening neogit + kind = "tab", + -- kind = "vsplit", + -- customize displayed signs + signs = { + -- { CLOSED, OPENED } + section = { ">", "v" }, + item = { ">", "v" }, + hunk = { "", "" }, + }, + integrations = { + -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `sindrets/diffview.nvim`. + -- The diffview integration enables the diff popup, which is a wrapper around `sindrets/diffview.nvim`. + -- + -- Requires you to have `sindrets/diffview.nvim` installed. + -- use { + -- 'TimUntersberger/neogit', + -- requires = { + -- 'nvim-lua/plenary.nvim', + -- 'sindrets/diffview.nvim' + -- } + -- } + -- + diffview = false + }, + -- Setting any section to `false` will make the section not render at all + sections = { + untracked = { + folded = false + }, + unstaged = { + folded = false + }, + staged = { + folded = false + }, + stashes = { + folded = true + }, + unpulled = { + folded = true + }, + unmerged = { + folded = false + }, + recent = { + folded = true + }, + }, + -- override/add mappings + mappings = { + -- modify status buffer mappings + status = { + -- Adds a mapping with "B" as key that does the "BranchPopup" command + ["B"] = "BranchPopup", + -- Removes the default mapping of "s" + ["s"] = "", + } + } +} diff --git a/plugin-confs/null-ls.lua b/plugin-confs/null-ls.lua new file mode 100644 index 0000000..ff9843c --- /dev/null +++ b/plugin-confs/null-ls.lua @@ -0,0 +1,121 @@ +local null_ls = require("null-ls") +local helpers = require("null-ls.helpers") + +require("null-ls").setup({ + on_attach = function(client) + if client.supports_method "textDocument/formatting" then + vim.cmd([[ + augroup LspFormatting + autocmd! * + autocmd BufWritePre lua vim.lsp.buf.formatting_sync() + augroup END + ]]) + end + end, + sources = { + null_ls.builtins.completion.spell, + null_ls.builtins.completion.luasnip, + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.code_actions.shellcheck, + null_ls.builtins.diagnostics.cppcheck, + null_ls.builtins.diagnostics.gitlint, + null_ls.builtins.diagnostics.jsonlint, + -- require("null-ls").builtins.diagnostics.luacheck, + null_ls.builtins.diagnostics.markdownlint, + null_ls.builtins.diagnostics.pylint, + null_ls.builtins.diagnostics.pydocstyle.with({ + extra_args = { "--config=$ROOT/setup.cfg" } + }), + null_ls.builtins.diagnostics.vint, + null_ls.builtins.diagnostics.shellcheck.with({ + extra_args = { "-s", "bash", "-o", "add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables" } + }), + null_ls.builtins.diagnostics.ansiblelint, + null_ls.builtins.formatting.json_tool, + -- require("null-ls").builtins.formatting.lua_format, + null_ls.builtins.formatting.markdownlint, + null_ls.builtins.formatting.prettier, + -- handled by lsp server + -- require("null-ls").builtins.formatting.rustfmt, + null_ls.builtins.formatting.shfmt.with({ + filetypes = { "sh", "bash" }, + extra_args = { "-i", "0", "-ci", "-sr" } + }), + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.isort, + -- null_ls.builtins.formatting.tidy + }, +}) + +-- local markdownlint = { +-- method = null_ls.methods.DIAGNOSTICS, +-- filetypes = { "markdown" }, +-- -- null_ls.generator creates an async source +-- -- that spawns the command with the given arguments and options +-- generator = null_ls.generator({ +-- command = "markdownlint", +-- args = { "--stdin" }, +-- to_stdin = true, +-- from_stderr = true, +-- -- choose an output format (raw, json, or line) +-- format = "line", +-- check_exit_code = function(code, stderr) +-- local success = code <= 1 + +-- if not success then +-- -- can be noisy for things that run often (e.g. diagnostics), but can +-- -- be useful for things that run on demand (e.g. formatting) +-- print(stderr) +-- end + +-- return success +-- end, +-- -- use helpers to parse the output from string matchers, +-- -- or parse it manually with a function +-- on_output = helpers.diagnostics.from_patterns({ +-- { +-- pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]], +-- groups = { "row", "col", "message" }, +-- }, +-- { +-- pattern = [[:(%d+) [%w-/]+ (.*)]], +-- groups = { "row", "message" }, +-- }, +-- }), +-- }), +-- } + +-- local shellcheck = { +-- method = null_ls.methods.DIAGNOSTICS, +-- filetypes = { "sh", "bash", "zsh", "fish" }, +-- generator = null_ls.generator({ +-- command = "shellcheck", +-- args = { "-s", "bash", "-o", "all", "-e", "2250" }, +-- from_stderr = true, +-- format = "line", +-- check_exit_code = function(code, stderr) +-- local success = code <= 1 + +-- if not success then +-- -- can be noisy for things that run often (e.g. diagnostics), but can +-- -- be useful for things that run on demand (e.g. formatting) +-- print(stderr) +-- end + +-- return success +-- end, +-- on_output = helpers.diagnostics.from_patterns({ +-- { +-- pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]], +-- groups = { "row", "col", "message" }, +-- }, +-- { +-- pattern = [[:(%d+) [%w-/]+ (.*)]], +-- groups = { "row", "message" }, +-- }, +-- }), +-- }), +-- } + +-- null_ls.register(markdownlint) +-- null_ls.register(shellcheck) diff --git a/plugin-confs/nvim-cmp.lua b/plugin-confs/nvim-cmp.lua new file mode 100644 index 0000000..e3e9246 --- /dev/null +++ b/plugin-confs/nvim-cmp.lua @@ -0,0 +1,192 @@ +-- Setup nvim-cmp. +local cmp = require 'cmp' +local lspkind = require('lspkind') +local capabilities = require('cmp_nvim_lsp').default_capabilities() +local lspconfig = require('lspconfig') +-- luasnip setup +local luasnip = require 'luasnip' +local highlight = require('cmp.utils.highlight') + +local has_words_before = function() + if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil +end + +lspkind.init({ + symbol_map = { + Copilot = "", + }, +}) + +vim.api.nvim_set_hl(0, "CmpItemKindCopilot", {fg ="#6CC644"}) + +cmp.setup({ + snippet = { + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + capabilities = capabilities, + mapping = { + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + -- [""] = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_next_item() + -- elseif luasnip.expand_or_jumpable() then + -- luasnip.expand_or_jump() + -- else + -- fallback() + -- end + -- end, { "i", "s" }), + [""] = vim.schedule_wrap(function(fallback) + if cmp.visible() and has_words_before() then + cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) + else + fallback() + end + end), + [''] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + end + end, { "i", "s"}), + }, + window = { + completion = { + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None", + col_offset = -3, + side_padding = 0, + border = "rounded", + borderchars = { + "─", + "│", + "─", + "│", + "╭", + "╮", + "╯", + "╰", + }, + }, + documentation = { + border = "rounded", + borderchars = { + "─", + "│", + "─", + "│", + "╭", + "╮", + "╯", + "╰", + }, + -- padding = 15, + } + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 75 })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. strings[1] .. " " + kind.menu = " (" .. strings[2] .. ")" + + return kind + end, + -- format = lspkind.cmp_format({ + -- mode = 'symbol_text', -- show only symbol annotations + -- menu = ({ + -- buffer = "[Buffer]", + -- nvim_lsp = "[LSP]", + -- luasnip = "[LuaSnip]", + -- nvim_lua = "[Lua]", + -- latex_symbols = "[Latex]", + -- }) + -- }) + }, + sources = cmp.config.sources({ + { name = "copilot", group_index = 2 }, + { name = 'nvim_lsp', group_index = 2 }, + { name = 'nvim_lsp_signature_help', group_index = 2 }, + { name = "path", group_index = 2 }, + { name = 'luasnip', group_index = 2 }, -- For luasnip users. + { + 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 = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }), + sorting = { + priority_weight = 2, + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + } +}) + + +local servers = { 'bashls', 'jedi_language_server', 'sqlls', 'jsonls', 'yamlls', 'vimls', 'dotls', 'dockerls' } +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + -- on_attach = my_custom_on_attach, + capabilities = capabilities, + } +end + + +cmp.event:on("menu_opened", function() + vim.b.copilot_suggestion_hidden = true +end) +cmp.event:on("menu_closed", function() + vim.b.copilot_suggestion_hidden = false +end) diff --git a/plugin-confs/nvim-docs-view.lua b/plugin-confs/nvim-docs-view.lua new file mode 100644 index 0000000..c4cc71b --- /dev/null +++ b/plugin-confs/nvim-docs-view.lua @@ -0,0 +1,6 @@ +require("docs-view").setup { + -- position = "right", + -- width = 90, + position = "bottom", + height = 20, +} diff --git a/plugin-confs/nvimtree.lua b/plugin-confs/nvimtree.lua new file mode 100644 index 0000000..6de2dfe --- /dev/null +++ b/plugin-confs/nvimtree.lua @@ -0,0 +1,106 @@ +require 'nvim-tree'.setup { + disable_netrw = false, + hijack_netrw = false, + open_on_setup = false, + ignore_ft_on_setup = {}, + -- auto_close = false, + open_on_tab = false, + hijack_cursor = false, + update_cwd = false, + -- update_to_buf_dir = { + -- enable = true, + -- auto_open = true, + -- }, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + } + }, + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {} + }, + system_open = { + cmd = nil, + args = {} + }, + filters = { + dotfiles = false, + custom = {} + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 35, + -- height = 35, + hide_root_folder = false, + side = 'left', + -- auto_resize = false, + mappings = { + custom_only = false, + list = {} + }, + number = false, + relativenumber = false, + signcolumn = "yes" + }, + trash = { + cmd = "trash", + require_confirm = true + }, + actions = { + change_dir = { + global = false, + }, + open_file = { + quit_on_open = false, + } + } +} + +-- local tree_cb = require'nvim-tree.config'.nvim_tree_callback + +-- default mappings +local list = { + { key = { "", "o", "<2-LeftMouse>" }, action = "edit" }, + { key = { "O" }, action = "edit_no_picker" }, + { key = { "<2-RightMouse>", "" }, action = "cd" }, + { key = "", action = "vsplit" }, + { key = "", action = "split" }, + { key = "", action = "tabnew" }, + { key = "<", action = "prev_sibling" }, + { key = ">", action = "next_sibling" }, + { key = "P", action = "parent_node" }, + { key = "", action = "close_node" }, + { key = "", action = "preview" }, + { key = "K", action = "first_sibling" }, + { key = "J", action = "last_sibling" }, + { key = "I", action = "toggle_ignored" }, + { key = "H", action = "toggle_dotfiles" }, + { key = "R", action = "refresh" }, + { key = "a", action = "create" }, + { key = "d", action = "remove" }, + { key = "D", action = "trash" }, + { key = "r", action = "rename" }, + { key = "", action = "full_rename" }, + { key = "x", action = "cut" }, + { key = "c", action = "copy" }, + { key = "p", action = "paste" }, + { key = "y", action = "copy_name" }, + { key = "Y", action = "copy_path" }, + { key = "gy", action = "copy_absolute_path" }, + { key = "[c", action = "prev_git_item" }, + { key = "]c", action = "next_git_item" }, + { key = "-", action = "dir_up" }, + { key = "s", action = "system_open" }, + { key = "q", action = "close" }, + { key = "g?", action = "toggle_help" }, +} diff --git a/plugin-confs/onedarkpro.lua b/plugin-confs/onedarkpro.lua new file mode 100644 index 0000000..5835f59 --- /dev/null +++ b/plugin-confs/onedarkpro.lua @@ -0,0 +1,29 @@ +local onedarkpro = require("onedarkpro") +onedarkpro.setup({ + theme = "onedark", + -- colors = {}, -- Override default colors. Can specify colors for "onelight" or "onedark" themes by passing in a table + -- hlgroups = {}, -- Override default highlight groups + plugins = { -- Override which plugins highlight groups are loaded + native_lsp = true, + polygot = true, + treesitter = true, + }, + styles = { + comments = "italic", + functions = "italic,bold", + keywords = "italic,bold", + strings = "NONE", + variables = "bold" + }, + options = { + bold = true, -- Use the themes opinionated bold styles? + italic = true, -- Use the themes opinionated italic styles? + underline = true, -- Use the themes opinionated underline styles? + undercurl = false, -- Use the themes opinionated undercurl styles? + cursorline = true, -- Use cursorline highlighting? + transparency = false, -- Use a transparent background? + terminal_colors = false, -- Use the theme's colors for Neovim's :terminal? + window_unfocussed_color = false, -- When the window is out of focus, change the normal background? + } +}) +onedarkpro.load() diff --git a/plugin-confs/presence.lua b/plugin-confs/presence.lua new file mode 100644 index 0000000..a801714 --- /dev/null +++ b/plugin-confs/presence.lua @@ -0,0 +1,22 @@ +require("presence"):setup({ + -- General options + auto_update = true, -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`) + neovim_image_text = "The One True Text Editor", -- Text displayed when hovered over the Neovim image + main_image = "neovim", -- Main image display (either "neovim" or "file") + -- client_id = "793271441293967371", -- Use your own Discord application client id (not recommended) + log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error") + debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(, true)`) + enable_line_number = false, -- Displays the current line number instead of the current project + blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches + buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "