From f00e435d4e5ae5abae96fd4a036abd1966bca94b Mon Sep 17 00:00:00 2001 From: Arkaprabha Chakraborty Date: Fri, 9 Jun 2023 06:38:22 +0530 Subject: [PATCH] Commits: Call the new plugins Add gruvbox colorscheme Turn off jump on jumpable for code snippets Add git integration Remove unnecessary keybinds Change keybinds for LSP functions Turn off format on buffer write Add plugin sources Remove 'help' from syntax highlighting Add transparency option Add visible indentations Changes to be committed: modified: init.lua modified: lua/colorschemes.lua modified: lua/completions.lua new file: lua/git-integration.lua modified: lua/keybinds.lua modified: lua/lsp-config.lua modified: lua/lsp-format.lua modified: lua/plugins.lua modified: lua/syntax-highlight.lua new file: lua/transparency.lua new file: lua/visible-indents.lua --- init.lua | 3 ++ lua/colorschemes.lua | 97 ++++++++++++++++++++++++++++------------ lua/completions.lua | 8 ++-- lua/git-integration.lua | 47 +++++++++++++++++++ lua/keybinds.lua | 5 --- lua/lsp-config.lua | 50 ++++++++++++++++++--- lua/lsp-format.lua | 34 +++++++------- lua/plugins.lua | 96 ++++++++++++++++++++++----------------- lua/syntax-highlight.lua | 2 +- lua/transparency.lua | 33 ++++++++++++++ lua/visible-indents.lua | 12 +++++ 11 files changed, 283 insertions(+), 104 deletions(-) create mode 100644 lua/git-integration.lua create mode 100644 lua/transparency.lua create mode 100644 lua/visible-indents.lua diff --git a/init.lua b/init.lua index 5b38017..48099ce 100644 --- a/init.lua +++ b/init.lua @@ -11,3 +11,6 @@ require("fuzzy-finder") require("syntax-highlight") require("lsp-config") require("lsp-format") +require("transparency") +require("visible-indents") +require("git-integration") diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua index 32746db..2fbebf7 100644 --- a/lua/colorschemes.lua +++ b/lua/colorschemes.lua @@ -1,31 +1,4 @@ -local colorscheme = "base16-black-metal" -- Set colorscheme - -if colorscheme == "base16-black-metal" then - local ok, base16 = pcall(require, "base16-colorscheme") - if not ok then - return - end - base16.setup({ - --base00 = "#000000", - base00 = "#171717", - base01 = "#121212", - base02 = "#222222", - --base03 = "#333333", - base03 = "#494949", - base04 = "#999999", - base05 = "#c1c1c1", - base06 = "#999999", - base07 = "#c1c1c1", - base08 = "#5f8787", - base09 = "#aaaaaa", - base0A = "#a06666", - base0B = "#dd9999", - base0C = "#aaaaaa", - base0D = "#888888", - base0E = "#999999", - base0F = "#444444", - }) -end +local colorscheme = "gruvbox" -- Set colorscheme { gruvbox, onedark, catppuccin, nord, dracula } if colorscheme == "onedark" then -- Onedark Default Configuration @@ -138,7 +111,12 @@ if colorscheme == "gruvbox" then undercurl = true, underline = true, bold = true, - italic = true, + italic = { + strings = true, + comments = true, + operators = false, + folds = true, + }, strikethrough = true, invert_selection = false, invert_signs = false, @@ -165,3 +143,64 @@ if colorscheme == "nord" then vim.cmd([[colorscheme nord]]) end + +if colorscheme == "everforest" then + local ok, everforest = pcall(require, "nord") + if not ok then + return + end + + vim.cmd([[colorscheme everforest]]) +end + +if colorscheme == "dracula" then + local ok, dracula = pcall(require, "dracula") + if not ok then + return + end + + dracula.setup({ + -- customize dracula color palette + 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 + show_end_of_buffer = true, -- default false + -- use transparent background + transparent_bg = true, -- default false + -- set custom lualine background color + lualine_bg_color = "#44475a", -- default nil + -- set italic comment + italic_comment = true, -- default false + -- overrides the default highlights see `:h synIDattr` + overrides = { + -- Examples + -- NonText = { fg = dracula.colors().white }, -- set NonText fg to white + -- NvimTreeIndentMarker = { link = "NonText" }, -- link to NonText highlight + -- Nothing = {} -- clear highlight of Nothing + }, + }) + + vim.cmd([[colorscheme dracula]]) +end diff --git a/lua/completions.lua b/lua/completions.lua index 4dc86eb..725827a 100644 --- a/lua/completions.lua +++ b/lua/completions.lua @@ -40,8 +40,8 @@ cmp.setup({ cmp.select_next_item() -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() -- they way you will only jump inside the snippet region - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() + --elseif luasnip.expand_or_jumpable() then + -- luasnip.expand_or_jump() elseif has_words_before() then cmp.complete() else @@ -51,8 +51,8 @@ cmp.setup({ [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) + --elseif luasnip.jumpable(-1) then + -- luasnip.jump(-1) else fallback() end diff --git a/lua/git-integration.lua b/lua/git-integration.lua new file mode 100644 index 0000000..bddf9e6 --- /dev/null +++ b/lua/git-integration.lua @@ -0,0 +1,47 @@ +local ok, gitsigns = pcall(require, "gitsigns") +if not ok then + return +end + +gitsigns.setup({ + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + 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 = ", - ", + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { + enable = false, + }, +}) diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 53dbc2c..f7aa2fd 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -18,11 +18,6 @@ vim.g.maplocalleader = ";" -- Command Mode = 'c', -- Normal mode -- --- Basic commands -bind("n", "w", ":w", opts) -bind("n", "e", ":q", opts) -bind("n", "q", ":qa", opts) - -- Nvim tree bind("n", "", ":NvimTreeToggle", opts) diff --git a/lua/lsp-config.lua b/lua/lsp-config.lua index 70411be..23b0788 100644 --- a/lua/lsp-config.lua +++ b/lua/lsp-config.lua @@ -43,10 +43,48 @@ mason_lspconfig.setup_handlers({ }, }) end, - --["rust_analyzer"] = function() - -- local rt_ok, rust_tools = pcall(require, "rust-tools") - -- if rt_ok then - -- rust_tools.setup({}) - -- end - --end, + ["rust_analyzer"] = function() + local rt_ok, rust_tools = pcall(require, "rust-tools") + if rt_ok then + rust_tools.setup({}) + end + end, +}) + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set("n", "e", vim.diagnostic.open_float) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next) +vim.keymap.set("n", "q", vim.diagnostic.setloclist) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workLeader_folders())) + end, opts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "f", function() + vim.lsp.buf.format({ async = true }) + end, opts) + end, }) diff --git a/lua/lsp-format.lua b/lua/lsp-format.lua index ea47e5d..139f311 100644 --- a/lua/lsp-format.lua +++ b/lua/lsp-format.lua @@ -13,21 +13,21 @@ require("null-ls").setup({ null_ls.builtins.formatting.clang_format, }, -- you can reuse a shared lspconfig on_attach callback here - on_attach = function(client, 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() - vim.lsp.buf.format({ - bufnr = bufnr, - filter = function() - return client.name == "null-ls" - end, - }) - end, - }) - end - end, + --on_attach = function(client, 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() + -- vim.lsp.buf.format({ + -- bufnr = bufnr, + -- filter = function() + -- return client.name == "null-ls" + -- end, + -- }) + -- end, + -- }) + -- end + --end, }) diff --git a/lua/plugins.lua b/lua/plugins.lua index b71d65f..f63b199 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,64 +1,76 @@ local ok, packer = pcall(require, "packer") if not ok then - return + return end packer.startup(function(use) - -- Base16 colorscheme - use("RRethy/nvim-base16") + -- Visible indentation + use("lukas-reineke/indent-blankline.nvim") - -- Nord colorscheme - use("shaunsingh/nord.nvim") + -- Git integration + use("lewis6991/gitsigns.nvim") - -- Onedark colorscheme - use("navarasu/onedark.nvim") + -- Transparency enabler + use("xiyaowong/transparent.nvim") - -- Gruvbox colorscheme - use("ellisonleao/gruvbox.nvim") + -- Nord colorscheme + use("shaunsingh/nord.nvim") - -- Catppuccin colorscheme - use({ "catppuccin/nvim", as = "catppuccin" }) + -- Dracula colorscheme + use("Mofiqul/dracula.nvim") - -- Plugin manager - use("wbthomason/packer.nvim") + -- Onedark colorscheme + use("navarasu/onedark.nvim") - -- Terminal - use({ "akinsho/toggleterm.nvim", tag = "*" }) + -- Gruvbox colorscheme + use("ellisonleao/gruvbox.nvim") - -- File tree - use({ "nvim-tree/nvim-tree.lua", requires = { "nvim-tree/nvim-web-devicons" }, tag = "nightly" }) + --Everforest colorscheme + use("sainnhe/everforest") - -- Statusline - use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons", opt = true } }) + -- Catppuccin colorscheme + use({ "catppuccin/nvim", as = "catppuccin" }) - -- Buffer tabs - use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) + -- Plugin manager + use("wbthomason/packer.nvim") - use({ "nvim-telescope/telescope.nvim", tag = "0.1.x", requires = { { "nvim-lua/plenary.nvim" } } }) + -- Terminal + use({ "akinsho/toggleterm.nvim", tag = "*" }) - -- LSP manager - use("williamboman/mason.nvim") - use("williamboman/mason-lspconfig.nvim") - use("neovim/nvim-lspconfig") + -- File tree + use({ "nvim-tree/nvim-tree.lua", requires = { "nvim-tree/nvim-web-devicons" }, tag = "nightly" }) - -- Formatting - use("jose-elias-alvarez/null-ls.nvim") + -- Statusline + use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons", opt = true } }) - -- Snippets - use("L3MON4D3/LuaSnip") --snippet engine - use("rafamadriz/friendly-snippets") -- a bunch of snippets to use + -- Buffer tabs + use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) - -- Completions - use("hrsh7th/nvim-cmp") -- The completion plugin - use("hrsh7th/cmp-buffer") -- buffer completions - use("hrsh7th/cmp-path") -- path completions - use("saadparwaiz1/cmp_luasnip") -- snippet completions - use("onsails/lspkind.nvim") - use("hrsh7th/cmp-nvim-lsp") + use({ "nvim-telescope/telescope.nvim", tag = "0.1.x", requires = { { "nvim-lua/plenary.nvim" } } }) - -- Syntax highlighting - use("nvim-treesitter/nvim-treesitter") + -- LSP manager + use("williamboman/mason.nvim") + use("williamboman/mason-lspconfig.nvim") + use("neovim/nvim-lspconfig") - -- Rust tools - --use("simrat39/rust-tools.nvim") + -- Formatting + use("jose-elias-alvarez/null-ls.nvim") + + -- Snippets + use("L3MON4D3/LuaSnip") --snippet engine + use("rafamadriz/friendly-snippets") -- a bunch of snippets to use + + -- Completions + use("hrsh7th/nvim-cmp") -- The completion plugin + use("hrsh7th/cmp-buffer") -- buffer completions + use("hrsh7th/cmp-path") -- path completions + use("saadparwaiz1/cmp_luasnip") -- snippet completions + use("onsails/lspkind.nvim") + use("hrsh7th/cmp-nvim-lsp") + + -- Syntax highlighting + use("nvim-treesitter/nvim-treesitter") + + -- Rust tools + use("simrat39/rust-tools.nvim") end) diff --git a/lua/syntax-highlight.lua b/lua/syntax-highlight.lua index 975b084..1245f40 100644 --- a/lua/syntax-highlight.lua +++ b/lua/syntax-highlight.lua @@ -5,7 +5,7 @@ end nvim_treesitter.setup({ -- A list of parser names, or "all" (the four listed parsers should always be installed) - ensure_installed = { "c", "help", "lua", "vim", "cpp", "rust" }, + ensure_installed = { "c", "lua", "vim", "cpp", "rust" }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, -- Automatically install missing parsers when entering buffer diff --git a/lua/transparency.lua b/lua/transparency.lua new file mode 100644 index 0000000..452c958 --- /dev/null +++ b/lua/transparency.lua @@ -0,0 +1,33 @@ +local ok, transparency = pcall(require, "transparency") +if not ok then + return +end + +transparency.setup({ + groups = { -- table: default groups + "Normal", + "NormalNC", + "Comment", + "Constant", + "Special", + "Identifier", + "Statement", + "PreProc", + "Type", + "Underlined", + "Todo", + "String", + "Function", + "Conditional", + "Repeat", + "Operator", + "Structure", + "LineNr", + "NonText", + "SignColumn", + "CursorLineNr", + "EndOfBuffer", + }, + extra_groups = {}, -- table: additional groups that should be cleared + exclude_groups = {}, -- table: groups you don't want to clear +}) diff --git a/lua/visible-indents.lua b/lua/visible-indents.lua new file mode 100644 index 0000000..4010259 --- /dev/null +++ b/lua/visible-indents.lua @@ -0,0 +1,12 @@ +local ok, indent_blankline = pcall(require, "indent_blankline") +if not ok then + return +end + +vim.cmd([[let g:indent_blankline_char = '¦']]) + +indent_blankline.setup({ + -- for example, context is off by default, use this to turn it on + show_current_context = true, + show_current_context_start = true, +})