rice/dots/.config/nvim/lua/main/init.lua
2022-07-11 15:57:59 +03:00

155 lines
4.2 KiB
Lua

require "plugins"
-- thanks nvchad for the telescope config
require("telescope").setup {
defaults = {
vimgrep_arguments = {
"rg",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
prompt_prefix = "",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
file_sorter = require("telescope.sorters").get_fuzzy_file,
file_ignore_patterns = { "node_modules" },
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
path_display = { "absolute" },
winblend = 0,
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,
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
}
}
require("nvim-treesitter.configs").setup {
highlight = {
enable = true,
disable = {},
},
indent = {
enable = false,
disable = {},
},
ensure_installed = {
"json",
"html",
"scss",
"javascript",
"css",
"c",
"cpp",
"rust",
"lua"
},
}
-- Add additional capabilities supported by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
-- Language servers
require"lspconfig".clangd.setup{
capabilities = capabilities
}
local luasnip = require "luasnip"
local cmp = require "cmp"
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ select = true })
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
{ name = "nvim_lsp" },
},
}
require("bufferline").setup{}
local options = {
tabstop = 4,
shiftwidth = 4,
expandtab = true,
smartindent = true,
smartcase = true,
mouse = "a",
termguicolors = true,
cmdheight = 1
}
local init = {
"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>",
"let g:gruvbox_material_palette = 'material'",
"let g:gruvbox_material_background = 'soft'",
"let g:gruvbox_material_better_performance = '1'",
"colorscheme gruvbox-material",
"set nohlsearch"
}
for k, v in pairs(options) do
vim.o[k] = v
end
for i, v in pairs(init) do
vim.cmd(v)
end