From 78152fa48c79f8258c36b74bcfd4582fd2cbb78f Mon Sep 17 00:00:00 2001 From: siduck76 Date: Sun, 7 Mar 2021 19:52:30 +0530 Subject: [PATCH] initial commit --- init.lua | 40 +++++++++ lua/bufferline/lua.lua | 54 ++++++++++++ lua/lsp_config/lua.lua | 61 +++++++++++++ lua/mappings/lua.lua | 9 ++ lua/nvimTree/lua.lua | 88 +++++++++++++++++++ lua/pluginsList/lua.lua | 21 +++++ lua/statusline/lua.lua | 170 +++++++++++++++++++++++++++++++++++++ lua/treesitter/lua.lua | 13 +++ lua/utils/lua.lua | 22 +++++ lua/web-devicons/lua.lua | 62 ++++++++++++++ plugin/packer_compiled.vim | 109 ++++++++++++++++++++++++ 11 files changed, 649 insertions(+) create mode 100644 init.lua create mode 100644 lua/bufferline/lua.lua create mode 100644 lua/lsp_config/lua.lua create mode 100644 lua/mappings/lua.lua create mode 100644 lua/nvimTree/lua.lua create mode 100644 lua/pluginsList/lua.lua create mode 100644 lua/statusline/lua.lua create mode 100644 lua/treesitter/lua.lua create mode 100644 lua/utils/lua.lua create mode 100644 lua/web-devicons/lua.lua create mode 100644 plugin/packer_compiled.vim diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6a53fe1 --- /dev/null +++ b/init.lua @@ -0,0 +1,40 @@ +-- load plugins +require('pluginsList.lua') + +require('utils.lua') +require('nvimTree.lua') +require('lsp_config.lua') + +require'colorizer'.setup() + +local cmd = vim.cmd +local g = vim.g +local indent = 2 + +cmd 'colorscheme base16-onedark' +cmd 'syntax enable' +cmd 'syntax on' + +g.auto_save = 1 + +g.indentLine_enabled = 1 +g.indentLine_char_list = {'▏'} + +require('treesitter.lua') +require('statusline.lua') +require('bufferline.lua') +require('mappings.lua') +require('web-devicons.lua') + +-- highlights +cmd("hi LineNr guibg=NONE") +cmd("hi SignColumn guibg=NONE") +cmd("hi VertSplit guibg=NONE") +cmd("highlight DiffAdd guifg=#81A1C1 guibg = none") +cmd("highlight DiffChange guifg =#3A3E44 guibg = none") +cmd("highlight DiffModified guifg = #81A1C1 guibg = none") +cmd("hi EndOfBuffer guifg=#282c34") + +-- tree folder name , icon color +cmd("highlight NvimTreeFolderIcon guifg = #61afef") +cmd("highlight NvimTreeFolderName guifg = #61afef") diff --git a/lua/bufferline/lua.lua b/lua/bufferline/lua.lua new file mode 100644 index 0000000..3765b4e --- /dev/null +++ b/lua/bufferline/lua.lua @@ -0,0 +1,54 @@ +vim.o.termguicolors = true + +require'bufferline'.setup{ + options = { + buffer_close_icon= '', + modified_icon = '●', + close_icon = '', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 14, + max_prefix_length = 13, + tab_size = 18, + enforce_regular_tabs = true , + view = "multiwindow" , + show_buffer_close_icons = true , + separator_style = "thin" + }, + + highlights = { + background = { + guifg = comment_fg, + guibg = '#282c34' + }, + fill = { + guifg = comment_fg, + guibg = '#282c34' + }, + buffer_selected = { + guifg = normal_fg, + guibg = '#3A3E44', + gui = "bold" + }, + separator_visible = { + guifg = '#282c34' , + guibg = '#282c34' + }, + separator_selected = { + guifg = '#282c34' , + guibg = '#282c34' + }, + separator = { + guifg = '#282c34' , + guibg = '#282c34' + }, + indicator_selected = { + guifg = '#282c34' , + guibg = '#282c34' + }, + modified_selected = { + guifg = string_fg, + guibg = '#3A3E44' + } + }; +} diff --git a/lua/lsp_config/lua.lua b/lua/lsp_config/lua.lua new file mode 100644 index 0000000..23890bc --- /dev/null +++ b/lua/lsp_config/lua.lua @@ -0,0 +1,61 @@ +vim.cmd [[ packadd nvim-lspconfig ]] +vim.cmd [[ packadd completion-nvim ]] + +require'lspconfig'.html.setup{} + +local nvim_lsp = require('lspconfig') +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) + elseif client.resolved_capabilities.document_range_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) + end + + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec([[ + 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 + ]], false) + end +end + +-- Use a loop to conveniently both setup defined servers +local servers = { "html" , "cssls" , "tsserver"} +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { on_attach = on_attach } +end + +-- keybinds +vim.api.nvim_set_keymap('i', '', 'pumvisible() ? "\\" : "\\"', { noremap = true, expr = true }) +vim.api.nvim_set_keymap('i', '', 'pumvisible() ? "\\" : "\\"', { noremap = true, expr = true }) diff --git a/lua/mappings/lua.lua b/lua/mappings/lua.lua new file mode 100644 index 0000000..8d1d148 --- /dev/null +++ b/lua/mappings/lua.lua @@ -0,0 +1,9 @@ +local function map(mode, lhs, rhs, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +-- keybind list + +map('', 'c', '"+y') diff --git a/lua/nvimTree/lua.lua b/lua/nvimTree/lua.lua new file mode 100644 index 0000000..50a39c7 --- /dev/null +++ b/lua/nvimTree/lua.lua @@ -0,0 +1,88 @@ +vim.cmd [[packadd nvim-tree.lua]] + +vim.o.termguicolors = true + +vim.g.nvim_tree_side = 'left' +vim.g.nvim_tree_width = 24 +vim.g.nvim_tree_ignore = { '.git', 'node_modules', '.cache' } +vim.g.nvim_tree_auto_open = 0 +vim.g.nvim_tree_auto_close = 0 +vim.g.nvim_tree_quit_on_open = 0 +vim.g.nvim_tree_follow = 1 +vim.g.nvim_tree_indent_markers = 1 +vim.g.nvim_tree_hide_dotfiles = 1 +vim.g.nvim_tree_git_hl = 1 +vim.g.nvim_tree_root_folder_modifier = ':~' +vim.g.nvim_tree_tab_open = 1 +vim.g.nvim_tree_allow_resize = 1 + +vim.g.nvim_tree_show_icons = { + git = 1, + folders = 1, + files = 1, + } + +vim.g.nvim_tree_icons = { + default = ' ', + symlink = ' ', + + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★" + }, + folder = { + default = "", + open = "", + symlink = "", + } + } + +local get_lua_cb = function (cb_name) + return string.format(":lua require'nvim-tree'.on_keypress('%s')", cb_name) +end + +-- Mappings for nvimtree + +vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle', { + noremap = true, + silent = true + }) + +-- [[ +vim.api.nvim_set_keymap('n', '', ':NvimTreeRefresh', { + noremap = true, + silent = true + }) + + -- ]] + +vim.g.nvim_tree_bindings = { + [""] = get_lua_cb("edit"), + ["o"] = get_lua_cb("edit"), + ["<2-LeftMouse>"] = get_lua_cb("edit"), + ["<2-RightMouse>"] = get_lua_cb("cd"), + [""] = get_lua_cb("cd"), + [""] = get_lua_cb("vsplit"), + [""] = get_lua_cb("split"), + [""] = get_lua_cb("tabnew"), + [""] = get_lua_cb("close_node"), + [""] = get_lua_cb("close_node"), + [""] = get_lua_cb("preview"), + ["I"] = get_lua_cb("toggle_ignored"), + ["H"] = get_lua_cb("toggle_dotfiles"), + ["R"] = get_lua_cb("refresh"), + ["a"] = get_lua_cb("create"), + ["d"] = get_lua_cb("remove"), + ["r"] = get_lua_cb("rename"), + [""] = get_lua_cb("full_rename"), + ["x"] = get_lua_cb("cut"), + ["c"] = get_lua_cb("copy"), + ["p"] = get_lua_cb("paste"), + ["[c"] = get_lua_cb("prev_git_item"), + ["]c"] = get_lua_cb("next_git_item"), + ["-"] = get_lua_cb("dir_up"), + ["q"] = get_lua_cb("close"), +} diff --git a/lua/pluginsList/lua.lua b/lua/pluginsList/lua.lua new file mode 100644 index 0000000..d42c3af --- /dev/null +++ b/lua/pluginsList/lua.lua @@ -0,0 +1,21 @@ +-- check if packer is installed (~/local/share/nvim/site/pack) +local packer_exists = pcall(vim.cmd, [[packadd packer.nvim]]) + +return require('packer').startup(function() + use { 'kyazdani42/nvim-web-devicons'} + use {'neovim/nvim-lspconfig'} + use {'nvim-lua/completion-nvim'} + use {'wbthomason/packer.nvim', opt = true} + use { 'nvim-lua/plenary.nvim'} + use { 'lewis6991/gitsigns.nvim'} + use { 'glepnir/galaxyline.nvim'} + use { 'tweekmonster/startuptime.vim'} + use { 'akinsho/nvim-bufferline.lua'} + use { '907th/vim-auto-save'} + use { 'kyazdani42/nvim-tree.lua'} + use { 'nvim-treesitter/nvim-treesitter'} + use { 'chriskempson/base16-vim'} + use { 'norcalli/nvim-colorizer.lua'} + use { 'Yggdroot/indentLine'} + use { 'ryanoasis/vim-devicons'} +end) diff --git a/lua/statusline/lua.lua b/lua/statusline/lua.lua new file mode 100644 index 0000000..ee5ef6d --- /dev/null +++ b/lua/statusline/lua.lua @@ -0,0 +1,170 @@ +local gl = require('galaxyline') +local gls = gl.section +gl.short_line_list = {'LuaTree','vista','dbui'} + +local colors = { + bg = '#282c34', + line_bg = '#282c34', + fg = '#D8DEE9', + fg_green = '#65a380', + yellow = '#A3BE8C', + cyan = '#22262C', + darkblue = '#61afef', + green = '#afd700', + orange = '#FF8800', + purple = '#252930', + magenta = '#c678dd', + blue = '#22262C'; + red = '#ec5f67', + firored = '#DF8890', + lightbg = '#3C4048', + nord = '#81A1C1', + nordYel = '#EBCB8B' +} + +gls.left[2] = { + ViMode = { + provider = function() + return ' 󰀘 ' + end, + highlight = {colors.bg,colors.nord}, + separator = ' ', + separator_highlight = {colors.lightbg,colors.lightbg}, + }, +} + +gls.left[3] ={ + FileIcon = { + provider = 'FileIcon', + condition = buffer_not_empty, + highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.lightbg}, + }, +} + +gls.left[4] = { + FileName = { + provider = {'FileName','FileSize'}, + separator = ' ', + separator_highlight = {colors.line_bg,colors.lightbg}, + condition = buffer_not_empty, + highlight = {colors.fg,colors.lightbg} + } +} + +gls.left[5] = { + GitIcon = { + provider = function() return '  ' end, + condition = require('galaxyline.provider_vcs').check_git_workspace, + highlight = {colors.fg,colors.line_bg}, + } +} + +gls.left[6] = { + GitBranch = { + provider = 'GitBranch', + condition = require('galaxyline.provider_vcs').check_git_workspace, + highlight = {'#8FBCBB',colors.line_bg,'bold'}, + } +} + +local checkwidth = function() + local squeeze_width = vim.fn.winwidth(0) / 2 + if squeeze_width > 40 then + return true + end + return false +end + +gls.left[7] = { + DiffAdd = { + provider = 'DiffAdd', + condition = checkwidth, + icon = '  ', + highlight = {colors.nordYel,colors.line_bg}, + } +} + +gls.left[8] = { + DiffModified = { + provider = 'DiffModified', + condition = checkwidth, + icon = ' ', + highlight = {colors.orange,colors.line_bg}, + } +} + +gls.left[9] = { + DiffRemove = { + provider = 'DiffRemove', + condition = checkwidth, + icon = ' ', + highlight = {colors.red,colors.line_bg}, + } +} + +gls.left[10] = { + LeftEnd = { + provider = function() return ' ' end, + separator = ' ', + separator_highlight = {colors.line_bg,colors.line_bg}, + highlight = {colors.line_bg,colors.line_bg} + } +} + +gls.left[11] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = {colors.red,colors.bg} + } +} + +gls.left[12] = { + Space = { + provider = function () return ' ' end, + highlight = {colors.line_bg,colors.line_bg} + } +} + +gls.left[13] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = {colors.blue,colors.bg}, + } +} + +gls.right[1]= { + FileFormat = { + provider = 'FileFormat', + separator = ' ', + separator_highlight = {colors.firored,colors.firored}, + highlight = {colors.bg,colors.firored}, + } +} + +gls.right[3] = { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = {colors.firored,colors.firored}, + highlight = {colors.bg,colors.fg}, + } +} +gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = {colors.purple,colors.bg}, + highlight = {colors.fg,colors.purple} + } +} + +gls.short_line_right[1] = { + BufferIcon = { + provider= 'BufferIcon', + separator = ' ', + separator_highlight = {colors.purple,colors.bg}, + highlight = {colors.fg,colors.purple} + } +} diff --git a/lua/treesitter/lua.lua b/lua/treesitter/lua.lua new file mode 100644 index 0000000..c88478d --- /dev/null +++ b/lua/treesitter/lua.lua @@ -0,0 +1,13 @@ +local ts_config = require("nvim-treesitter.configs") + +ts_config.setup { + ensure_installed = { + "javascript","html","css","bash","cpp","rust","lua" + }, + + highlight = { + enable = true, + use_languagetree = true, + }, +} + diff --git a/lua/utils/lua.lua b/lua/utils/lua.lua new file mode 100644 index 0000000..121b440 --- /dev/null +++ b/lua/utils/lua.lua @@ -0,0 +1,22 @@ +local scopes = { o = vim.o, b = vim.bo, w = vim.wo} + +local function opt(scope, key, value) + scopes[scope][key] = value + if scope ~= 'o' then scopes['o'][key] = value end +end + +opt('o', 'hidden', true) +opt('o', 'ignorecase', true) +opt('o', 'splitbelow', true) +opt('o', 'splitright', true) +opt('o', 'termguicolors', true) +opt('w', 'number', true) +opt('o', 'numberwidth' , 2) + +opt('o' ,'mouse' , "a") + +opt('w', 'signcolumn' , "yes") +opt('o' , 'cmdheight' , 1) +opt('o' , 'updatetime' , 250) +opt('o' , 'clipboard' , 'unnamedplus') + diff --git a/lua/web-devicons/lua.lua b/lua/web-devicons/lua.lua new file mode 100644 index 0000000..16728b1 --- /dev/null +++ b/lua/web-devicons/lua.lua @@ -0,0 +1,62 @@ +require'nvim-web-devicons'.setup { + + override = { + html = { + icon = "", + color = "#DE8C92", + name = "html" + }, + css = { + icon = "", + color = "#61afef", + name = "css" + }, + js = { + icon = "", + color = "#EBCB8B", + name = "js" + }, + 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" + } + }; + +} diff --git a/plugin/packer_compiled.vim b/plugin/packer_compiled.vim new file mode 100644 index 0000000..b919611 --- /dev/null +++ b/plugin/packer_compiled.vim @@ -0,0 +1,109 @@ +" Automatically generated packer.nvim plugin loader code + +if !has('nvim-0.5') + echohl WarningMsg + echom "Invalid Neovim version for packer.nvim!" + echohl None + finish +endif + +packadd packer.nvim + +try + +lua << END +local package_path_str = "/home/sid/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/sid/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/sid/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/sid/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/sid/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s)) + if not success then + print('Error running ' .. component .. ' for ' .. name) + error(result) + end + return result +end + +_G.packer_plugins = { + ["base16-vim"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/base16-vim" + }, + ["completion-nvim"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/completion-nvim" + }, + ["galaxyline.nvim"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/galaxyline.nvim" + }, + ["gitsigns.nvim"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/gitsigns.nvim" + }, + indentLine = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/indentLine" + }, + ["nvim-bufferline.lua"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/nvim-bufferline.lua" + }, + ["nvim-colorizer.lua"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/nvim-lspconfig" + }, + ["nvim-tree.lua"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/nvim-treesitter" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = false, + needs_bufread = false, + path = "/home/sid/.local/share/nvim/site/pack/packer/opt/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/plenary.nvim" + }, + ["startuptime.vim"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/startuptime.vim" + }, + ["vim-auto-save"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/vim-auto-save" + }, + ["vim-devicons"] = { + loaded = true, + path = "/home/sid/.local/share/nvim/site/pack/packer/start/vim-devicons" + } +} + +END + +catch + echohl ErrorMsg + echom "Error in packer_compiled: " .. v:exception + echom "Please check your config for correctness" + echohl None +endtry