diff --git a/README.md b/README.md index 060feff..a3bec95 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ I do try to make sure playbooks work on RHEL/Debian based distros via gitlab CI. This repo was created for my own use, But feel free to use it as you please. -Looking just for dotfiles? take a look at `files/dotfiles` +Looking just for dotfiles? Take a look at `files/dotfiles` ### Requirements: - git diff --git a/files/dotfiles/nvim/init.lua b/files/dotfiles/nvim/init.lua new file mode 100644 index 0000000..ea773f2 --- /dev/null +++ b/files/dotfiles/nvim/init.lua @@ -0,0 +1,2 @@ +require("user") + diff --git a/files/dotfiles/nvim/lua/user/cmp.lua b/files/dotfiles/nvim/lua/user/cmp.lua new file mode 100644 index 0000000..ccb5974 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/cmp.lua @@ -0,0 +1,54 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, _ = pcall(require, "luasnip") +if snip_status_ok then + require("luasnip/loaders/from_vscode").lazy_load() +end + +local lspkind_status_ok, lspkind = pcall(require, "lspkind") +if not lspkind_status_ok then + return +end + + + + +local source_mapping = { + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + cmp_tabnine = "[TN]", + path = "[Path]", +} + +cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + }), + + formatting = { + format = function(entry, vim_item) + vim_item.kind = lspkind.presets.default[vim_item.kind] + local menu = source_mapping[entry.source.name] + vim_item.menu = menu + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "path" }, + { name = "luasnip" }, + { name = "buffer" }, + }, +}) diff --git a/files/dotfiles/nvim/lua/user/colors.lua b/files/dotfiles/nvim/lua/user/colors.lua new file mode 100644 index 0000000..7117057 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/colors.lua @@ -0,0 +1,11 @@ +-- Coloschemes that support TreeSitter: +-- https://github.com/nvim-treesitter/nvim-treesitter/wiki/Colorschemes +local vars = require('user.vars') + +local gb_status_ok, gruvbox = pcall(require, 'gruvbox') +if gb_status_ok then + gruvbox.setup({}) +end + +vim.opt.background = "dark" +vim.cmd("colorscheme " .. vars.colorscheme) diff --git a/files/dotfiles/nvim/lua/user/init.lua b/files/dotfiles/nvim/lua/user/init.lua new file mode 100644 index 0000000..5dc93d6 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/init.lua @@ -0,0 +1,14 @@ +require("user.settings") +require("user.packer") +require("user.init_plugins") + +require("user.lsp") +require("user.cmp") +require("user.treesitter") +require("user.keymaps") +require("user.colors") +require("user.lualine") + +-- Make sure plugins are installed +--vim.cmd(":PackerClean") +vim.cmd(":PackerInstall") diff --git a/files/dotfiles/nvim/lua/user/init_plugins.lua b/files/dotfiles/nvim/lua/user/init_plugins.lua new file mode 100644 index 0000000..a584fc9 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/init_plugins.lua @@ -0,0 +1,30 @@ +-- +-- setup some plugins +-- + +-- NvimTree empty setup using defaults +local tree_status_ok, tree = pcall(require, "nvim-tree") +if tree_status_ok then + tree.setup() +end + +-- Git signs (Gutter) +local gitsigns_status_ok, gitsigns = pcall(require, "gitsigns") +if gitsigns_status_ok then + gitsigns.setup() +end + +-- Telescope +local _, _ = pcall(require, "telescope.builtin") + +-- Autopairs +local autopairs_status_ok, autopairs = pcall(require, "nvim-autopairs") +if autopairs_status_ok then + autopairs.setup {} +end + +-- Illuminate +--local status_ok, illuminate = pcall(require, "illuminate") +--if status_ok then +-- illuminate.configure() +--end diff --git a/files/dotfiles/nvim/lua/user/keymap_func.lua b/files/dotfiles/nvim/lua/user/keymap_func.lua new file mode 100644 index 0000000..53c5cd3 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/keymap_func.lua @@ -0,0 +1,20 @@ +local M = {} + +local function bind(op, outer_opts) + outer_opts = outer_opts or {noremap = true} + return function(lhs, rhs, opts) + opts = vim.tbl_extend("force", + outer_opts, + opts or {} + ) + vim.keymap.set(op, lhs, rhs, opts) + end +end + +M.nmap = bind("n", {noremap = false}) +M.nnoremap = bind("n") +M.vnoremap = bind("v") +M.xnoremap = bind("x") +M.inoremap = bind("i") + +return M diff --git a/files/dotfiles/nvim/lua/user/keymaps.lua b/files/dotfiles/nvim/lua/user/keymaps.lua new file mode 100644 index 0000000..755363b --- /dev/null +++ b/files/dotfiles/nvim/lua/user/keymaps.lua @@ -0,0 +1,39 @@ +local Remap = require("user.keymap_func") +local nnoremap = Remap.nnoremap +local vnoremap = Remap.vnoremap +local inoremap = Remap.inoremap +local xnoremap = Remap.xnoremap +local nmap = Remap.nmap + +local telescope = require('telescope.builtin') + + +-- NvimTree toggle/refresh/findfile +nnoremap("", ":NvimTreeToggle") +nnoremap("r", ":NvimTreeRefresh") +nnoremap("n", ":NvimTreeFindFile") + +-- Telescope +nnoremap("", telescope.find_files) +nnoremap("", telescope.live_grep) +nnoremap("", telescope.current_buffer_fuzzy_find) + +-- Copy to system clipboard +vnoremap('y', '"+y') +nnoremap('Y', '"+yg_') +nnoremap('y', '"+y') +nnoremap('yy', '"+yy') + +-- Paste from system clipboard +nnoremap('p', '"+p') +nnoremap('P', '"+P') +vnoremap('p', '"+p') +vnoremap('P', '"+P') + +-- Easy navigation on split screen +nnoremap('', '') +nnoremap('', '') +nnoremap('', '') +nnoremap('', '') + + diff --git a/files/dotfiles/nvim/lua/user/lsp/handlers.lua b/files/dotfiles/nvim/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..c2c6919 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lsp/handlers.lua @@ -0,0 +1,91 @@ +local M = {} + +M.setup = function() + local signs = { + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + -- show signs + signs = { + active = signs, + }, + update_in_insert = true, + underline = true, + severity_sort = true, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_highlight_document(client, bufnr) + if client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true }) + vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" } + vim.api.nvim_create_autocmd("CursorHold", { + callback = vim.lsp.buf.document_highlight, + buffer = bufnr, + group = "lsp_document_highlight", + desc = "Document Highlight", + }) + vim.api.nvim_create_autocmd("CursorMoved", { + callback = vim.lsp.buf.clear_references, + buffer = bufnr, + group = "lsp_document_highlight", + desc = "Clear All the References", + }) + vim.cmd [[ + highlight LspReferenceText guifg=NONE guibg=#928374 + highlight LspReferenceRead guifg=NONE guibg=#928374 + highlight LspReferenceWrite guifg=NONE guibg=#928374 + ]] + end +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + 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", "rn", "lua vim.lsp.buf.rename()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.format { async = true }", opts) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.server_capabilities.documentFormattingProvider = false + end + lsp_keymaps(bufnr) + lsp_highlight_document(client, bufnr) + vim.cmd [[autocmd BufWritePre lua vim.lsp.buf.formatting_sync()]] +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_ok then + return +end + +M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities) + +return M diff --git a/files/dotfiles/nvim/lua/user/lsp/init.lua b/files/dotfiles/nvim/lua/user/lsp/init.lua new file mode 100644 index 0000000..2f44705 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lsp/init.lua @@ -0,0 +1,8 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require "user.lsp.mason" +require("user.lsp.handlers").setup() + diff --git a/files/dotfiles/nvim/lua/user/lsp/mason.lua b/files/dotfiles/nvim/lua/user/lsp/mason.lua new file mode 100644 index 0000000..d6a72be --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lsp/mason.lua @@ -0,0 +1,46 @@ +local servers = { + "sumneko_lua", + "pyright", + "jsonls", +} + +local settings = { + ui = { + icons = { + package_installed = "", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, +} + +require("mason").setup(settings) +require("mason-lspconfig").setup({ + ensure_installed = servers, + automatic_installation = true, +}) + +local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status_ok then + return +end + +local opts = {} + +require('mason-lspconfig').setup_handlers({ + function(server) + opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + server = vim.split(server, "@")[1] + -- If we have special options for a given server - merge options with defaults + local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) + if require_ok then + opts = vim.tbl_deep_extend("force", conf_opts, opts) + end + + lspconfig[server].setup(opts) + + end, +}) diff --git a/files/dotfiles/nvim/lua/user/lsp/settings/jsonls.lua b/files/dotfiles/nvim/lua/user/lsp/settings/jsonls.lua new file mode 100644 index 0000000..b63a2ee --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lsp/settings/jsonls.lua @@ -0,0 +1,62 @@ +-- Find more schemas here: https://www.schemastore.org/json/ +local schemas = { + { + description = "TypeScript compiler configuration file", + fileMatch = { + "tsconfig.json", + "tsconfig.*.json", + }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + description = "Babel configuration", + fileMatch = { + ".babelrc.json", + ".babelrc", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + description = "ESLint config", + fileMatch = { + ".eslintrc.json", + ".eslintrc", + }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + description = "golangci-lint configuration file", + fileMatch = { + ".golangci.toml", + ".golangci.json", + }, + url = "https://json.schemastore.org/golangci-lint.json", + }, + { + description = "NPM configuration file", + fileMatch = { + "package.json", + }, + url = "https://json.schemastore.org/package.json", + }, +} + +local opts = { + settings = { + json = { + schemas = schemas, + }, + }, + setup = { + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) + end, + }, + }, + }, +} + +return opts diff --git a/files/dotfiles/nvim/lua/user/lsp/settings/pyright.lua b/files/dotfiles/nvim/lua/user/lsp/settings/pyright.lua new file mode 100644 index 0000000..6354274 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lsp/settings/pyright.lua @@ -0,0 +1,10 @@ +return { + settings = { + + python = { + analysis = { + typeCheckingMode = "off" + } + } + }, +} diff --git a/files/dotfiles/nvim/lua/user/lsp/settings/sumneko_lua.lua b/files/dotfiles/nvim/lua/user/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..0ac454a --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lsp/settings/sumneko_lua.lua @@ -0,0 +1,16 @@ +return { + settings = { + + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/files/dotfiles/nvim/lua/user/lualine.lua b/files/dotfiles/nvim/lua/user/lualine.lua new file mode 100644 index 0000000..10970aa --- /dev/null +++ b/files/dotfiles/nvim/lua/user/lualine.lua @@ -0,0 +1,12 @@ +local vars = require('user.vars') + +local status_ok, lualine = pcall(require, 'lualine') +if not status_ok then + return +end + +lualine.setup({ + options = { + theme = vars.colorscheme, + } +}) diff --git a/files/dotfiles/nvim/lua/user/packer.lua b/files/dotfiles/nvim/lua/user/packer.lua new file mode 100644 index 0000000..c9bb7d8 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/packer.lua @@ -0,0 +1,64 @@ +return require("packer").startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- LSP config + use { + 'neovim/nvim-lspconfig', + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/nvim-cmp', + 'onsails/lspkind.nvim', + 'nvim-lua/lsp_extensions.nvim', + 'glepnir/lspsaga.nvim', + 'simrat39/symbols-outline.nvim', + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + } + + -- file tree + use { + 'nvim-tree/nvim-web-devicons', + 'kyazdani42/nvim-tree.lua' + } + + -- Lightline + -- use 'itchyny/lightline.vim' + + -- Lualine (status line) + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } + + -- Gruvbox + use 'ellisonleao/gruvbox.nvim' + + -- Git Gutter + use { + 'lewis6991/gitsigns.nvim', + -- tag = 'release' + } + + -- Auto Pairs (brackets) + use { + "windwp/nvim-autopairs", + config = function() require("nvim-autopairs").setup {} end + } + + -- Telescope (fzf) + use { + 'nvim-telescope/telescope.nvim', + requires = { { 'nvim-lua/plenary.nvim' } } + } + + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' + } + + -- Beacon + use 'danilamihailov/beacon.nvim' +end) diff --git a/files/dotfiles/nvim/lua/user/settings.lua b/files/dotfiles/nvim/lua/user/settings.lua new file mode 100644 index 0000000..9449ce9 --- /dev/null +++ b/files/dotfiles/nvim/lua/user/settings.lua @@ -0,0 +1,46 @@ +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.errorbells = false + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = vim.fn.stdpath("data") .. "undo" +vim.opt.undofile = true + +-- vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +-- Give more space for displaying messages. +vim.opt.cmdheight = 1 + +-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +-- delays and poor user experience. +vim.opt.updatetime = 50 + +vim.opt.timeoutlen = 500 +vim.opt.ttimeoutlen = 0 +-- Don't pass messages to |ins-completion-menu|. +vim.opt.shortmess:append("c") + +vim.opt.colorcolumn = "80" + +vim.g.mapleader = " " +vim.wo.cursorline = true diff --git a/files/dotfiles/nvim/lua/user/treesitter.lua b/files/dotfiles/nvim/lua/user/treesitter.lua new file mode 100644 index 0000000..4ee777a --- /dev/null +++ b/files/dotfiles/nvim/lua/user/treesitter.lua @@ -0,0 +1,18 @@ +local ts_status_ok, treeconfig = pcall(require, "nvim-treesitter.configs") +if not ts_status_ok then + return +end +treeconfig.setup { + ensure_installed = "all", + sync_install = false, + ignore_install = { "" }, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = { "" }, -- list of language that will be disabled + additional_vim_regex_highlighting = true, + + }, + indent = { enable = true }, +} +-- Coloschemes that support TreeSitter: +-- https://github.com/nvim-treesitter/nvim-treesitter/wiki/Colorschemes diff --git a/files/dotfiles/nvim/lua/user/vars.lua b/files/dotfiles/nvim/lua/user/vars.lua new file mode 100644 index 0000000..fb8562f --- /dev/null +++ b/files/dotfiles/nvim/lua/user/vars.lua @@ -0,0 +1,5 @@ +local M = {} + +M.colorscheme = 'gruvbox' + +return M diff --git a/files/dotfiles/vimrc b/files/dotfiles/vimrc deleted file mode 100644 index e9115fb..0000000 --- a/files/dotfiles/vimrc +++ /dev/null @@ -1,410 +0,0 @@ -"============================================================================== -" vim-plug -"============================================================================== - -" plugins list - call plug#begin('~/.vim/plugged') - Plug 'sheerun/vim-polyglot' " A ton of language syntax - Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } " Markdown Preview - Plug 'pearofducks/ansible-vim' " Ansible support - Plug 'morhetz/gruvbox' " Gruvbox theme - Plug 'chriskempson/base16-vim' " Base 16 Themes - https://github.com/chriskempson/base16-vim - Plug 'sickill/vim-monokai' " Monokai Theme - Plug 'arcticicestudio/nord-vim' " Nord theme - Plug 'itchyny/lightline.vim' " vim status bar - Plug 'danilamihailov/beacon.nvim' " see cursor jumps easier - Plug 'shinchu/lightline-gruvbox.vim' " Gruvbox theme for status line - Plug 'lewis6991/gitsigns.nvim' " Git gutter and sings - Plug 'zivyangll/git-blame.vim' " Git blame - Plug 'lilydjwg/colorizer' " Displays the colors in file - Plug 'jiangmiao/auto-pairs' " Auto create bracket/parens/quote pairs - Plug 'vim-syntastic/syntastic' " coding-errors checker - Plug 'puremourning/vimspector' " Multi lang Debugger - Plug 'neoclide/coc.nvim', {'branch': 'release'} " Lanuage server integrations - Plug 'tpope/vim-fugitive' " git wrapper - Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " golang plugin for vim - Plug 'Yggdroot/indentLine' " Indentation LInes - Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Install fzf - Plug 'junegunn/fzf.vim' " Fuzzy search - Plug 'francoiscabrol/ranger.vim' " Ranger f - Plug 'kyazdani42/nvim-web-devicons' " for file icons - Plug 'kyazdani42/nvim-tree.lua' " File tree/browser - call plug#end() - -" Eliminate delay for esc insert->normal -set timeoutlen=1000 ttimeoutlen=0 -" Set encoding to utf8 -set encoding=UTF-8 -" Set no compatible -set nocompatible -" File type plugin on -filetype plugin on -" Turn on syntax -syntax on -" install plugins automatically -autocmd VimEnter * - \ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) - \| PlugInstall --sync | q - \| endif - -" remove unused plugins automatically -autocmd VimEnter * - \ if len(filter(split(globpath(g:plug_home, '*'), "\n"), 'isdirectory(v:val)')) - \ > len(filter(values(g:plugs), 'stridx(v:val.dir, g:plug_home) == 0')) - \| PlugClean | q - \| endif -" Initiate lua -lua require('gitsigns').setup() -" Init NvimTree -lua require'nvim-tree'.setup {} -" Toggle NerdTree with Ctrl+n -nnoremap :NvimTreeToggle -nnoremap r :NvimTreeRefresh -nnoremap n :NvimTreeFindFile -" Open fzf Files search Ctrl+p -map :Files -" Open file search Ctrl+f -map :BLines -" Open Global search Ctrl+s -map :Ag -" Indent Guides auto start -let g:indent_guides_enable_on_vim_startup = 1 - -" Toggle git blame s in normal mode -nnoremap s :call gitblame#echo() - -" Tab navigation and creation -map :tabnew -noremap :tabn - -" Insert mode navigation Alt+hjkl -imap -imap -imap -imap - -" Set line heighlight on by default -set cursorline -" Copy to clipboard -vnoremap y "+y -nnoremap Y "+yg_ -nnoremap y "+y -nnoremap yy "+yy - -" Paste from clipboard -nnoremap p "+p -nnoremap P "+P -vnoremap p "+p -vnoremap P "+P -" Enable mouse use in all modes -set mouse=a -" Auto highlight similar words when staying on a word after .5 sec -set updatetime=500 -augroup highlight_current_word - au! - au CursorHold * - \ if ( expand("%") != 'NvimTree_1' ) - \ | :silent! :exec 'match Search /\V\<' . expand('') . '\>/' - \ | endif -augroup END - - -"============================================================================== -" Beacon settings -"============================================================================== -let g:beacon_minimal_jump = 1 -"============================================================================== -" Sync NERDTree with file -"============================================================================== -" Check if NERDTree is open or active -function! IsNERDTreeOpen() - return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) -endfunction - -" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable -" file, and we're not in vimdiff -function! SyncTree() - if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff - NERDTreeFind - wincmd p - endif -endfunction - -" Highlight currently open buffer in NERDTree -autocmd BufRead * call SyncTree() - -" Nerdtree show hidden files -let NERDTreeShowHidden=1 -" Dont show .git folder -let NERDTreeIgnore=['\.git$'] - -"============================================================================== -" Theme settings -"============================================================================== - -let &t_8f = "\[38;2;%lu;%lu;%lum" -let &t_8b = "\[48;2;%lu;%lu;%lum" -set termguicolors -" Theme -colorscheme gruvbox -" Setting dark mode -" set background=dark - -"============================================================================== -" line number -"============================================================================== - -" turn hybrid line numbers on -:set number relativenumber -:set nu rnu - -:augroup numbertoggle -: autocmd! -: autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif -: autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif -:augroup END - -" Set current line number more visible -" hi clear CursorLine -augroup CLClear - autocmd! ColorScheme * hi clear CursorLine -augroup END - - -" open files at the last remember line -if has("autocmd") - au BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") - \| exe "normal! g`\"" - \| endif -endif - -"============================================================================== -" TAB settings -"============================================================================== - -"filetype plugin indent on - -" show existing tab with 4 spaces width -set tabstop=4 - -" when indenting with '>', use 4 spaces width -set shiftwidth=4 - -" On pressing tab, insert 4 spaces -set expandtab - - -"============================================================================== -" set column -"============================================================================== - -" set coding style limit at 80 chars -set colorcolumn=80 - -"============================================================================== -" mouse settings -"============================================================================== - -" enable mouse -set mouse=a - -"============================================================================== -" file title -"============================================================================== - -" always show current file title -set title - - -"============================================================================== -" normal mode mapping -"============================================================================== - -" mapping capsLock to ctrl -map CapsLock Ctrl - - -" this package is extending % to <> and other sifferent closures -packadd! matchit -:let b:match_words = '<:>,:' - -" enable ci( of all sorts to work from outside the parenthese -nnoremap ci( %ci( -nnoremap ci[ %ci[ -nnoremap ci{ %ci{ -" NOTE: use 'normal' for <> because % is not a regular vim command (package) -nnoremap ci< :normal %ci< - -" enable di( of all sorts to work from outside the parenthese -nnoremap di( %di( -nnoremap di[ %di[ -nnoremap di{ %di{ -" NOTE: use 'normal' for <> because % is not a regular vim command (package) -nnoremap di< :normal %di< - -" easy navigation on split screen -nnoremap -nnoremap -nnoremap -nnoremap - -" easy access to buffers -" \l : list buffers -" \b \f \g : go back/forward/last-used -" \d : delete buffer -nnoremap l :ls -nnoremap b :bp -nnoremap f :bn -nnoremap g :e# -nnoremap c :bd - -" make 'Y' act like 'D' and 'C' instead of working like 'yy' -nnoremap Y y$ - -"============================================================================== -" search settings -"============================================================================== - -" ignore CASE in search -set ignorecase - -" higlight search matches -set hlsearch - -"============================================================================== -" vim && tmux -"============================================================================== - -" makes split-navigation act differently when in vim\tmux -" in both cases navigation will be done with ctr + hjkl (without tmux prefix) -if exists('$TMUX') - function! TmuxOrSplitSwitch(wincmd, tmuxdir) - let previous_winnr = winnr() - silent! execute "wincmd " . a:wincmd - if previous_winnr == winnr() - call system("tmux select-pane -" . a:tmuxdir) - redraw! - endif - endfunction - - let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') - let &t_ti = "\]2;vim\\\" . &t_ti - let &t_te = "\]2;". previous_title . "\\\" . &t_te - - nnoremap :call TmuxOrSplitSwitch('h', 'L') - nnoremap :call TmuxOrSplitSwitch('j', 'D') - nnoremap :call TmuxOrSplitSwitch('k', 'U') - nnoremap :call TmuxOrSplitSwitch('l', 'R') -else - map h - map j - map k - map l -endif - - - -"============================================================================== -" split settings -"============================================================================== -" -" more intuitive default splits - set splitbelow - set splitright - -"============================================================================== -" Lightline.vim plugin & status line -"============================================================================== - -" make status line always visible -set laststatus=2 - -" NOTE: 'FugitiveHead' is 'vim-fugitive' plugin's function and depend on it -" configure lightline.vim status line -let g:lightline = { - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] - \ }, - \ 'component_function': { - \ 'gitbranch': 'FugitiveHead', - \ 'filename': 'LightlineFilename', - \ }, - \ } -" lightline colorscheme -" let g:lightline.colorscheme = 'gruvbox' -" function to get the filename from vim to lightline.vim -function! LightlineFilename() - return &filetype ==# 'vimfiler' ? vimfiler#get_status_string() : - \ &filetype ==# 'unite' ? unite#get_status_string() : - \ &filetype ==# 'vimshell' ? vimshell#get_status_string() : - \ expand('%') !=# '' ? expand('%') : '[No Name]' -endfunction - -let g:unite_force_overwrite_statusline = 0 -let g:vimfiler_force_overwrite_statusline = 0 -let g:vimshell_force_overwrite_statusline = 0 - -" actually this have no effect when lightline.vim plugin is installed -set statusline+=%f "relative path (use %F for absolute path) -set statusline+=%m "modified flag -set statusline+=%= "left/right separator -set statusline+=%l/%L "cursor line/total lines -set statusline+=\ %P "percent through file - -"============================================================================== -" Spelling settings -"============================================================================== - -" make spell checker underline errors with vim 'set spell' command -" Note: must appear after the last line that is altering colorscheme -hi clear SpellBad -hi SpellBad cterm=underline -set spell - -"============================================================================== -" Delete settings -"============================================================================== - -" make backspace always erase in insert mode and not only new inputs -set backspace=indent,eol,start - -"============================================================================== -" Fold settings -"============================================================================== - -set foldmethod=marker - - -"============================================================================== -" swp files -"============================================================================== - -" Don't use swapfile -set noswapfile - - - -"============================================================================== -" Coc Key mapping -"============================================================================== -"" Use to trigger completion. -if has('nvim') - inoremap coc#refresh() -else - inoremap coc#refresh() -endif -" Symbol renaming. -nmap (coc-rename) -" Hit tab go see documentation -nmap :silent call show_documentation() -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - elseif (coc#rpc#ready()) - call CocActionAsync('doHover') - else - execute '!' . &keywordprg . " " . expand('') - endif -endfunction diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 8a831ec..70afb13 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -10,7 +10,10 @@ - git - ranger - jq + - nodejs + - npm - man-db + - clang state: present - name: Some more packages (RedHat based) diff --git a/roles/gh_release_bin/tasks/main.yml b/roles/gh_release_bin/tasks/main.yml index 804cba6..adc6184 100644 --- a/roles/gh_release_bin/tasks/main.yml +++ b/roles/gh_release_bin/tasks/main.yml @@ -24,10 +24,10 @@ - name: Get latest version from local entry set_fact: - local_version: "{{ lookup('file', local_version_file, errors='ignore') }}" + local_version: "{{ lookup('file', local_version_file, errors='ignore') | default(NOT_FOUND) }}" version: "{{ version.stdout }}" tar_url: "{{ tar_url.stdout }}" - tar_download_location: "/tmp/{{ name }}.tar.gz" + tar_download_location: "/tmp/{{ name }}.tar.gz" failed_when: false - name: Unarchive the release diff --git a/roles/vim_user/tasks/main.yml b/roles/vim_user/tasks/main.yml index 8251985..b0ca40c 100644 --- a/roles/vim_user/tasks/main.yml +++ b/roles/vim_user/tasks/main.yml @@ -1,20 +1,9 @@ -- name: Install vim (RHEL based) +- name: Install neovim become: true package: name: - neovim - - the_silver_searcher state: present - when: ansible_facts['os_family'] == "RedHat" - -- name: Install vim (Debian based) - become: true - package: - name: - - neovim - - silversearcher-ag - state: present - when: ansible_facts['os_family'] == "Debian" - name: Prepare vim config directory file: @@ -22,33 +11,14 @@ state: directory mode: '0755' -- name: Setup vim plug - file: - path: ~/.local/share/nvim/site/autoload - state: directory - mode: '0755' +- name: clone Packer repo (Install packer) + ansible.builtin.git: + repo: https://github.com/wbthomason/packer.nvim.git + depth: 1 + dest: ~/.local/share/nvim/site/pack/packer/start/packer.nvim + update: no -- name: Install vim Plug - get_url: - url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - dest: ~/.local/share/nvim/site/autoload/plug.vim - -- name: "Copy vimrc file" +- name: Copy nvim config directory copy: - src: dotfiles/vimrc - dest: "~/.config/nvim/init.vim" - mode: preserve - changed_when: false - -- name: "Set vim colorscheme" - ansible.builtin.lineinfile: - path: "~/.config/nvim/init.vim" - regexp: "^colorscheme" - line: "colorscheme {{ theme }}" - changed_when: false - - #- name: "Set vim lightline colorscheme" - # ansible.builtin.lineinfile: - # path: "~/.vimrc" - # regexp: "^let g:lightline.colorscheme" - # line: "let g:lightline.colorscheme = '{{theme}}'" + src: dotfiles/nvim/ + dest: ~/.config/nvim/