Compare commits

...

5 commits

Author SHA1 Message Date
d6ef8b0fdc nvim: some fixes to configs. Fixed some first time rum errors 2022-11-06 22:23:46 +02:00
acf3c084b8 Merge branch 'update-2022-11-3' into 'main'
Update

See merge request sagidayan/linux-config!19
2022-11-06 17:24:39 +00:00
9b69012480
neovim: migrated config from vimscript to lua. 2022-11-06 17:40:09 +02:00
dd5aa469dc
tmux: Config update 2022-11-06 15:59:01 +02:00
4f5b52b6fd
zshrc: Added some options to uncomment or copy to a shellconfig
one ideal for server use, the other for workstation.
2022-11-03 17:56:19 +02:00
25 changed files with 583 additions and 460 deletions

View file

@ -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. 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: ### Requirements:
- git - git

View file

@ -0,0 +1,2 @@
require("user")

View file

@ -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({
['<Enter>'] = cmp.mapping.confirm({ select = true }),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = 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" },
},
})

View file

@ -0,0 +1,16 @@
-- Coloschemes that support TreeSitter:
-- https://github.com/nvim-treesitter/nvim-treesitter/wiki/Colorschemes
local vars = require('user.vars')
local have_theme = false
local gb_status_ok, gruvbox = pcall(require, 'gruvbox')
if gb_status_ok then
gruvbox.setup({})
have_theme = true
end
vim.opt.background = "dark"
if have_theme then
vim.cmd("colorscheme " .. vars.colorscheme)
end

View file

@ -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.lualine")
require("user.colors")
-- Make sure plugins are installed
--vim.cmd(":PackerClean")
vim.cmd(":PackerInstall")

View file

@ -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

View file

@ -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

View file

@ -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
-- NvimTree toggle/refresh/findfile
nnoremap("<C-n>", ":NvimTreeToggle<CR>")
nnoremap("<leader>r", ":NvimTreeRefresh<CR>")
nnoremap("<leader>n", ":NvimTreeFindFile<CR>")
-- Telescope
local telescope_status_ok, telescope = pcall(require, "telescope.builtin")
if telescope_status_ok then
nnoremap("<C-p>", telescope.find_files)
nnoremap("<C-s>", telescope.live_grep)
nnoremap("<C-f>", telescope.current_buffer_fuzzy_find)
end
-- Copy to system clipboard
vnoremap('<leader>y', '"+y')
nnoremap('<leader>Y', '"+yg_')
nnoremap('<leader>y', '"+y')
nnoremap('<leader>yy', '"+yy')
-- Paste from system clipboard
nnoremap('<leader>p', '"+p')
nnoremap('<leader>P', '"+P')
vnoremap('<leader>p', '"+p')
vnoremap('<leader>P', '"+P')
-- Easy navigation on split screen
nnoremap('<C-J>', '<C-W><C-J>')
nnoremap('<C-K>', '<C-W><C-K>')
nnoremap('<C-L>', '<C-W><C-L>')
nnoremap('<C-H>', '<C-W><C-H>')

View file

@ -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", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<M-f>", "<cmd>lua vim.lsp.buf.format { async = true }<CR>", 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 <buffer> 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

View file

@ -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()

View file

@ -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,
})

View file

@ -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

View file

@ -0,0 +1,10 @@
return {
settings = {
python = {
analysis = {
typeCheckingMode = "off"
}
}
},
}

View file

@ -0,0 +1,16 @@
return {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
}

View file

@ -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,
}
})

View file

@ -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)

View file

@ -0,0 +1,49 @@
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
-- Enable mouse support
vim.opt.mouse = 'a'

View file

@ -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

View file

@ -0,0 +1,5 @@
local M = {}
M.colorscheme = 'gruvbox'
return M

View file

@ -14,16 +14,16 @@ bind -n M-h select-pane -L
bind -n M-l select-pane -R bind -n M-l select-pane -R
bind -n M-k select-pane -U bind -n M-k select-pane -U
bind -n M-j select-pane -D bind -n M-j select-pane -D
# <prefix>-h|l|Left|Right # <prefix>-h|l|Left|Right
bind-key h previous-window bind-key h previous-window
bind-key Left previous-window bind-key Left previous-window
bind-key l next-window bind-key l next-window
bind-key Right next-window bind-key Right next-window
# Mouse mode # Mouse mode
setw -g mouse on setw -g mouse on
# Set easier window split keys # Set easier window split keys
bind-key | split-window -h -c "#{pane_current_path}" bind-key | split-window -h -c "#{pane_current_path}"
bind-key \\ split-window -h -c "#{pane_current_path}" bind-key \\ split-window -h -c "#{pane_current_path}"
@ -89,7 +89,7 @@ set -g history-limit 5000
bind -n C-k clear-history bind -n C-k clear-history
# Default Colors # Default Colors
set -g default-terminal "xterm-256color" set -g default-terminal "tmux-256color"
# Home/End support # Home/End support
bind -n End send-key C-e bind -n End send-key C-e
@ -153,9 +153,11 @@ set-window-option -g window-status-format '#[fg=#6699cc,bg=#2d4d2d] #I #[fg=#999
# make foreground window look like bold yellow foreground tab # make foreground window look like bold yellow foreground tab
set-window-option -g window-status-current-style none set-window-option -g window-status-current-style none
set-window-option -g window-status-current-format '#[fg=#f99157]#[fg=#6699cc]#I #[fg=#ffffff,bg=#6699cc] #W #[default]' set-window-option -g window-status-current-format '#[fg=#f99157]#[fg=#6699cc]#I #{?window_zoomed_flag,[🔎] ,}#[fg=#ffffff,bg=#6699cc] #W #[default]'
# active terminal yellow border, non-active white # active terminal yellow border, non-active white
set -g pane-border-style bg=default set -g pane-border-style bg=default
set -g pane-border-style fg="#999999" set -g pane-border-style fg="#999999"
set -g pane-active-border-style fg="#f99157" set -g pane-active-border-style fg="#f99157"
#set-hook -g after-resize-pane 'if "[ #{window_zoomed_flag} -eq 1 ]" "run \"tmux select-pane -P bg=red\"" "run \"tmux select-pane -P bg=black\""'

View file

@ -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 <leader>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 <C-n> :NvimTreeToggle<CR>
nnoremap <leader>r :NvimTreeRefresh<CR>
nnoremap <leader>n :NvimTreeFindFile<CR>
" Open fzf Files search Ctrl+p
map <C-p> :Files<CR>
" Open file search Ctrl+f
map <C-f> :BLines<CR>
" Open Global search Ctrl+s
map <C-s> :Ag<CR>
" Indent Guides auto start
let g:indent_guides_enable_on_vim_startup = 1
" Toggle git blame <leader>s in normal mode
nnoremap <Leader>s :<C-u>call gitblame#echo()<CR>
" Tab navigation and creation
map <C-t> :tabnew<CR>
noremap <Tab><Tab> :tabn<CR>
" Insert mode navigation Alt+hjkl
imap <M-h> <Left>
imap <M-l> <Right>
imap <M-j> <Down>
imap <M-k> <Up>
" Set line heighlight on by default
set cursorline
" Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>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('<cword>') . '\>/'
\ | 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 = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[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 = '<:>,<tag>:</tag>'
" 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 %<CR>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 %<CR>di<
" easy navigation on split screen
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" easy access to buffers
" \l : list buffers
" \b \f \g : go back/forward/last-used
" \d : delete buffer
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>c :bd<CR>
" 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 = "\<Esc>]2;vim\<Esc>\\" . &t_ti
let &t_te = "\<Esc>]2;". previous_title . "\<Esc>\\" . &t_te
nnoremap <silent> <C-h> :call TmuxOrSplitSwitch('h', 'L')<cr>
nnoremap <silent> <C-j> :call TmuxOrSplitSwitch('j', 'D')<cr>
nnoremap <silent> <C-k> :call TmuxOrSplitSwitch('k', 'U')<cr>
nnoremap <silent> <C-l> :call TmuxOrSplitSwitch('l', 'R')<cr>
else
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>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 <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Symbol renaming.
nmap <F2> <Plug>(coc-rename)
" Hit tab go see documentation
nmap <Tab> :silent call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction

View file

@ -100,7 +100,7 @@ source $ZSH/oh-my-zsh.sh
# alias zshconfig="mate ~/.zshrc" # alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh" # alias ohmyzsh="mate ~/.oh-my-zsh"
# Common # Common
source ~/.shellconfig/common.sh source ~/.shellconfig/common.sh
# Aliases # Aliases
source ~/.shellconfig/aliases.sh source ~/.shellconfig/aliases.sh
@ -114,5 +114,7 @@ if [ -d ~/.shellconfig/autocomplete ]; then
fi fi
# Start tmux if not in a session # Ideal for server use: Start tmux if not in a session
# [ -z $TMUX ] && ( tmux a || tmux ) # [ -z $TMUX ] && ( tmux a || tmux )
# Ideal for desktop use: If tmux is not open already - create a new session and open project manager
# [ -z $TMUX ] && (tmux new-session ~/.shellconfig/workspaces/open_workspace.sh)

View file

@ -10,7 +10,10 @@
- git - git
- ranger - ranger
- jq - jq
- nodejs
- npm
- man-db - man-db
- clang
state: present state: present
- name: Some more packages (RedHat based) - name: Some more packages (RedHat based)

View file

@ -24,10 +24,10 @@
- name: Get latest version from local entry - name: Get latest version from local entry
set_fact: 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 }}" version: "{{ version.stdout }}"
tar_url: "{{ tar_url.stdout }}" tar_url: "{{ tar_url.stdout }}"
tar_download_location: "/tmp/{{ name }}.tar.gz" tar_download_location: "/tmp/{{ name }}.tar.gz"
failed_when: false failed_when: false
- name: Unarchive the release - name: Unarchive the release

View file

@ -1,20 +1,9 @@
- name: Install vim (RHEL based) - name: Install neovim
become: true become: true
package: package:
name: name:
- neovim - neovim
- the_silver_searcher
state: present 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 - name: Prepare vim config directory
file: file:
@ -22,33 +11,14 @@
state: directory state: directory
mode: '0755' mode: '0755'
- name: Setup vim plug - name: clone Packer repo (Install packer)
file: ansible.builtin.git:
path: ~/.local/share/nvim/site/autoload repo: https://github.com/wbthomason/packer.nvim.git
state: directory depth: 1
mode: '0755' dest: ~/.local/share/nvim/site/pack/packer/start/packer.nvim
update: no
- name: Install vim Plug - name: Copy nvim config directory
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"
copy: copy:
src: dotfiles/vimrc src: dotfiles/nvim/
dest: "~/.config/nvim/init.vim" dest: ~/.config/nvim/
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}}'"