Treesitter, native language server, and telescope are currently integrated.
YQUFGGWU6WFCVRSGS3J577RQL7WJRQCLXVHHXVXDUJTMDRQC5BSQC
local setOptions = function()
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
local opt = function(scope, key, value)
scopes[scope][key] = value
if scope ~= 'o' then scopes['o'][key] = value end
end
vim.wo.relativenumber = true
vim.wo.number = true
vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
vim.bo.expandtab = true
vim.o.updatetime = 300
vim.o.splitbelow = true
vim.o.termguicolors = true
vim.o.showcmd = true
end
local latexSetUp = function()
vim.g.tex_flavor = 'latex'
vim.g.vimtex_view_general_viewer = 'zathura'
end
local cocSetUp = function()
vim.g.coc_global_extensions = { 'coc-omnisharp', 'coc-rust-analyzer', 'coc-go', 'coc-actions', 'coc-emmet', 'coc-css', 'coc-tsserver', 'coc-prettier', 'coc-deno','coc-html', 'coc-eslint', 'coc-texlab', 'coc-pyright'}
end
local gitgutterSetUp = function()
vim.g.gitgutter_sign_added = '✚'
vim.g.gitgutter_sign_modified = '✹'
vim.g.gitgutter_sign_removed = '-'
vim.g.gitgutter_sign_removed_first_line = '-'
vim.g.gitgutter_sign_modified_removed = '-'
end
local setUpAll = function()
setOptions()
gitgutterSetUp()
latexSetUp()
cocSetUp()
end
local setKeybindings = function()
--keybindings (would love to get vimp working)
vim.api.nvim_set_keymap('', '<c-n>', ':lua require(\'plugins/Terminal\').open(0.8, 0.8) <CR>', {silent = true})
vim.api.nvim_set_keymap('', '<c-t>', ':lua require(\'plugins/FZF\').open(\'vert new\', 0.8, 0.8) <CR>', {silent = true})
vim.api.nvim_set_keymap('', '<c-r>', ':lua require(\'plugins/FZF\').open(\'e\', 0.8, 0.8) <CR>', {silent = true})
vim.api.nvim_set_keymap('', '<A-h>', ':wincmd h <CR>', {})
vim.api.nvim_set_keymap('', '<A-j>', ':wincmd j <CR>', {})
vim.api.nvim_set_keymap('', '<A-k>', ':wincmd k <CR>', {})
vim.api.nvim_set_keymap('', '<A-l>', ':wincmd l <CR>', {})
vim.api.nvim_set_keymap('n', 'gd', '<Plug>(coc-definition)', {})
vim.api.nvim_set_keymap('n', 'gy', '<Plug>(coc-type-definition)', {})
vim.api.nvim_set_keymap('n', 'ga', '<Plug>(coc-codeaction)', {})
vim.api.nvim_command('autocmd BufWritePre * :silent! call CocActionAsync(\'format\')')
end
--local setOptions = function()
-- local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
-- local opt = function(scope, key, value)
-- scopes[scope][key] = value
-- if scope ~= 'o' then scopes['o'][key] = value end
-- end
-- vim.wo.relativenumber = true
-- vim.wo.number = true
-- vim.bo.shiftwidth = 4
-- vim.bo.tabstop = 4
-- vim.bo.expandtab = true
-- vim.o.updatetime = 300
-- vim.o.splitbelow = true
-- vim.o.termguicolors = true
-- vim.o.showcmd = true
--end
--
--local latexSetUp = function()
-- vim.g.tex_flavor = 'latex'
-- vim.g.vimtex_view_general_viewer = 'zathura'
--end
--
--local cocSetUp = function()
-- vim.g.coc_global_extensions = { 'coc-omnisharp', 'coc-rust-analyzer', 'coc-go', 'coc-actions', 'coc-emmet', 'coc-css', 'coc-tsserver', 'coc-prettier', 'coc-deno','coc-html', 'coc-eslint', 'coc-texlab', 'coc-pyright'}
--end
--
--local gitgutterSetUp = function()
-- vim.g.gitgutter_sign_added = '✚'
-- vim.g.gitgutter_sign_modified = '✹'
-- vim.g.gitgutter_sign_removed = '-'
-- vim.g.gitgutter_sign_removed_first_line = '-'
-- vim.g.gitgutter_sign_modified_removed = '-'
--end
--
--local setUpAll = function()
-- setOptions()
-- gitgutterSetUp()
-- latexSetUp()
-- cocSetUp()
--end
--
--local setKeybindings = function()
-- --keybindings (would love to get vimp working)
-- vim.api.nvim_set_keymap('', '<c-n>', ':lua require(\'plugins/Terminal\').open(0.8, 0.8) <CR>', {silent = true})
-- vim.api.nvim_set_keymap('', '<c-t>', ':lua require(\'plugins/FZF\').open(\'vert new\', 0.8, 0.8) <CR>', {silent = true})
-- vim.api.nvim_set_keymap('', '<c-r>', ':lua require(\'plugins/FZF\').open(\'e\', 0.8, 0.8) <CR>', {silent = true})
-- vim.api.nvim_set_keymap('', '<A-h>', ':wincmd h <CR>', {})
-- vim.api.nvim_set_keymap('', '<A-j>', ':wincmd j <CR>', {})
-- vim.api.nvim_set_keymap('', '<A-k>', ':wincmd k <CR>', {})
-- vim.api.nvim_set_keymap('', '<A-l>', ':wincmd l <CR>', {})
-- vim.api.nvim_set_keymap('n', 'gd', '<Plug>(coc-definition)', {})
-- vim.api.nvim_set_keymap('n', 'gy', '<Plug>(coc-type-definition)', {})
-- vim.api.nvim_set_keymap('n', 'ga', '<Plug>(coc-codeaction)', {})
-- vim.api.nvim_command('autocmd BufWritePre * :silent! call CocActionAsync(\'format\')')
--end
--
--
local main = function()
--set color
vim.cmd('colorscheme base16-gruvbox-dark-hard')
setKeybindings()
setUpAll()
--local main = function()
-- --set color
-- vim.cmd('colorscheme base16-gruvbox-dark-hard')
-- setKeybindings()
-- setUpAll()
--end
--
modules = {
"lsp_config",
"telescope_config",
"treesitter_config",
}
function main()
vim.cmd'colorscheme gruvbox'
vim.opt.updatetime = 250;
vim.opt.termguicolors = true
vim.opt.number = true;
vim.opt.smartindent = false;
vim.opt.autoindent = true;
vim.cmd'filetype plugin indent on'
vim.opt.relativenumber = true;
for _, module in ipairs(modules) do
require(module)
end
local t = require('utils').t
vim.opt.completeopt = "menuone,noselect";
vim.opt.inccommand = "nosplit";
-- go to the following link to see docs or do :help compe
-- https://github.com/hrsh7th/nvim-compe/blob/master/doc/compe.txt
require'compe'.setup {
enabled = true;
autocomplete = true;
debug = false;
preselect = 'enabled';
throttle_timeout = 80;
source_timeout = 200;
incomplete_delay = 400;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = true;
source = {
path = true;
buffer = true;
vsnip = true;
tags = true;
spell = true;
calc = true;
omni = true;
emoji = true;
nvim_lsp = true;
nvim_lua = true;
treesitter = true;
};
}
--shamelessly copied from nvim-compe's readme here:
--https://github.com/hrsh7th/nvim-compe
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 vim.fn.call("vsnip#available", {1}) == 1 then -- gonna be honest here, I don't use snippets
return t "<Plug>(vsnip-expand-or-jump)"
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>"
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<Plug>(vsnip-jump-prev)"
else
-- If <S-Tab> is not working in your terminal, change it to <C-h>
return t "<S-Tab>"
end
end
local function on_attach(_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
--Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', 'ga', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end
local nvim_lsp = require'lspconfig';
local servers = {"rust_analyzer", "pyright", "typescript-language-server"};
for _, server in ipairs(servers) do
nvim_lsp[server].setup {
on_attach = on_attach;
}
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})
vim.cmd'autocmd BufWritePre *.rs lua vim.lsp.buf.formatting()'
require'telescope'.setup{
defaults = {
vimgrep_arguments = {
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case'
},
prompt_position = "bottom",
prompt_prefix = "> ",
selection_caret = "> ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "descending",
layout_strategy = "horizontal",
layout_defaults = {
horizontal = {
mirror = false,
},
vertical = {
mirror = false,
},
},
file_sorter = require'telescope.sorters'.get_fuzzy_file,
file_ignore_patterns = {},
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
shorten_path = true,
winblend = 0,
width = 0.75,
preview_cutoff = 120,
results_height = 1,
results_width = 0.8,
border = {},
borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' },
color_devicons = true,
use_less = true,
set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil,
file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker
}
}
vim.api.nvim_set_keymap("n", "<C-F>", "<cmd>Telescope find_files<CR>", {noremap=true;})
vim.api.nvim_set_keymap("n", "<C-G>", "<cmd>Telescope live_grep<CR>", {noremap=true;})
require'nvim-treesitter.configs'.setup {
ensure_installed = {"rust", "lua"},
ignore_install = {},
highlight = {
enable = true,
},
}
local function t(term)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
return {
t = t;
}