Last active
June 5, 2021 16:47
-
-
Save huskercane/6667d9350dc88d0c6f0c11e7f667f4ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cmd = vim.cmd | |
cmd 'packadd paq-nvim' | |
local paq = require('paq-nvim').paq | |
paq{'savq/paq-nvim', opt=true} | |
paq {'nvim-treesitter/nvim-treesitter', run=':TSUpdate'} | |
paq {'nvim-treesitter/playground'} | |
paq {'neovim/nvim-lspconfig'} | |
paq {'hrsh7th/nvim-compe'} | |
paq {'nvim-lua/popup.nvim'} | |
paq {'nvim-lua/plenary.nvim'} | |
paq {'nvim-telescope/telescope.nvim'} | |
paq {'ray-x/lsp_signature.nvim'} | |
paq {'jeetsukumaran/vim-markology'} | |
paq {'tpope/vim-fugitive'} | |
paq {'airblade/vim-gitgutter'} | |
paq {'vim-scripts/LargeFile'} | |
paq {'joshdick/onedark.vim'} | |
paq {'morhetz/gruvbox'} | |
paq {'tomasiser/vim-code-dark'} | |
paq {'majutsushi/tagbar'} | |
paq {'Yggdroot/indentLine'} | |
paq {'martinda/Jenkinsfile-vim-syntax'} | |
paq {'tfnico/vim-gradle'} | |
paq {'vim-airline/vim-airline'} | |
paq {'vim-airline/vim-airline-themes'} | |
paq {'martinda/Jenkinsfile-vim-syntax'} | |
paq {'tfnico/vim-gradle'} | |
paq {'vim-airline/vim-airline'} | |
paq {'vim-airline/vim-airline-themes'} | |
local lsp = require 'lspconfig' | |
lsp.pyright.setup{} | |
lsp.bashls.setup{} | |
lsp.dockerls.setup{} | |
lsp.jdtls.setup{} | |
lsp.jsonls.setup { | |
commands = { | |
Format = { | |
function() | |
vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0}) | |
end | |
} | |
} | |
} | |
lsp.tsserver.setup{} | |
local lsps = require 'lsp_signature' | |
lsps.on_attach() | |
-- Compe setup | |
local compe = require 'compe' | |
compe.setup { | |
enabled = true; | |
autocomplete = true; | |
debug = false; | |
min_length = 1; | |
preselect = 'enable'; | |
throttle_time = 80; | |
source_timeout = 200; | |
incomplete_delay = 400; | |
max_abbr_width = 100; | |
max_kind_width = 100; | |
max_menu_width = 100; | |
documentation = true; | |
source = { | |
path = true; | |
nvim_lsp = true; | |
}; | |
} | |
local t = function(str) | |
return vim.api.nvim_replace_termcodes(str, true, true, true) | |
end | |
local check_back_space = function() | |
local col = vim.fn.col('.') - 1 | |
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then | |
return true | |
else | |
return false | |
end | |
end | |
-- Use (s-)tab to: | |
--- move to prev/next item in completion menuone | |
--- jump to prev/next snippet's placeholder | |
_G.tab_complete = function() | |
if vim.fn.pumvisible() == 1 then | |
return t "<C-n>" | |
elseif check_back_space() then | |
return t "<Tab>" | |
else | |
return vim.fn['compe#complete']() | |
end | |
end | |
_G.s_tab_complete = function() | |
if vim.fn.pumvisible() == 1 then | |
return t "<C-p>" | |
else | |
return t "<S-Tab>" | |
end | |
end | |
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) | |
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true}) | |
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) | |
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) | |
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 | |
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 | |
-------------------- OPTIONS ------------------------------- | |
local indent = 4 | |
cmd 'colorscheme gruvbox' -- Put your favorite colorscheme here | |
opt('b', 'expandtab', true) -- Use spaces instead of tabs | |
opt('b', 'shiftwidth', indent) -- Size of an indent | |
opt('b', 'smartindent', true) -- Insert indents automatically | |
opt('o', 'smarttab', true) -- Insert indents automatically | |
opt('b', 'tabstop', indent) -- Number of spaces tabs count for | |
opt('o', 'completeopt', 'menuone,noinsert,noselect') -- Completion options (for deoplete) | |
opt('o', 'hidden', true) -- Enable modified buffers in background | |
opt('o', 'ignorecase', true) -- Ignore case | |
opt('o', 'joinspaces', false) -- No double spaces with join after a dot | |
opt('o', 'scrolloff', 4 ) -- Lines of context | |
opt('o', 'shiftround', true) -- Round indent | |
opt('o', 'sidescrolloff', 8 ) -- Columns of context | |
opt('o', 'smartcase', true) -- Don't ignore case with capitals | |
opt('o', 'splitbelow', true) -- Put new windows below current | |
opt('o', 'splitright', true) -- Put new windows right of current | |
opt('o', 'termguicolors', true) -- True color support | |
opt('o', 'wildmode', 'list:longest') -- Command-line completion mode | |
opt('w', 'list', true) -- Show some invisible characters (tabs...) | |
opt('w', 'number', true) -- Print line number | |
opt('w', 'relativenumber', true) -- Relative line numbers | |
opt('w', 'wrap', false) | |
opt('o', 'gfn', 'Fantasque Sans Mono 12, Fira Code') | |
-- Follwing does not work | |
vim.o.background = "dark" | |
cmd("let g:airline_theme='gruvbox'") | |
-- Telescope maps | |
-- " Find files using Telescope command-line sugar. | |
-- nnoremap <leader>ff <cmd>Telescope find_files<cr> | |
map('n', '<leader>ff', '<cmd>Telescope find_files<CR>') | |
-- nnoremap <leader>fg <cmd>Telescope live_grep<cr> | |
map('n', '<leader>fg', '<cmd>Telescope live_grep<CR>') | |
-- nnoremap <leader>fb <cmd>Telescope buffers<cr> | |
map('n', '<leader>fb', '<cmd>Telescope buffers<CR>') | |
-- nnoremap <leader>fh <cmd>Telescope help_tags<cr> | |
map('n', '<leader>fh', '<cmd>Telescope help_tags<CR>') | |
-- | |
-- " Using lua functions | |
-- nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr> | |
-- nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr> | |
-- nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr> | |
-- nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr> | |
map('', '<leader>c', '"+y') -- Copy to clipboard in normal, visual, select and operator modes | |
map('i', '<C-u>', '<C-g>u<C-u>') -- Make <C-u> undo-friendly | |
map('i', '<C-w>', '<C-g>u<C-w>') -- Make <C-w> undo-friendly | |
-- <Tab> to navigate the completion menu | |
map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true}) | |
map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true}) | |
map('n', '<C-l>', '<cmd>noh<CR>') -- Clear highlights | |
map('n', '<leader>o', 'm`o<Esc>``') -- Insert a newline in normal mode | |
-- map('o', 'ff', '<C | |
-- noremap <leader>cd :cd %:p:h<CR> | |
map('', '<leader>cd', ':cd %:p:h<CR>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment