diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua new file mode 100644 index 0000000..9f488b5 --- /dev/null +++ b/dot_config/nvim/init.lua @@ -0,0 +1,12 @@ +-- options +require('options') + +-- packages +require('pack') + +-- plugin stuff +require('plugins.setups') +require('plugins.telescope') +require('plugins.lspconfig') +require('plugins.treesitter') +require('plugins.compe') diff --git a/dot_config/nvim/lua/common.lua b/dot_config/nvim/lua/common.lua new file mode 100644 index 0000000..9d47eca --- /dev/null +++ b/dot_config/nvim/lua/common.lua @@ -0,0 +1,13 @@ +local vim = vim +local M = {} + +function M.set_keymap(mode, from, to) + local opts = {noremap = true, silent = false} + vim.api.nvim_set_keymap(mode, from, to, opts) +end + +function M.nvim_set_keymap(mode, from, to, opts) + vim.api.nvim_set_keymap(mode, from, to, opts) +end + +return M diff --git a/dot_config/nvim/lua/options.lua b/dot_config/nvim/lua/options.lua new file mode 100644 index 0000000..e24092d --- /dev/null +++ b/dot_config/nvim/lua/options.lua @@ -0,0 +1,59 @@ +local cmd = vim.cmd +local opt = vim.opt +local has = vim.fn.has + +cmd('filetype plugin indent on') +cmd('syntax enable') + +-- system +opt.encoding = 'utf-8' +opt.fileencoding = 'utf-8' +opt.fileencodings = {'utf-8'} +opt.backup = false -- no .bak +opt.swapfile = false -- no .swap +opt.undofile = true -- use undo file +opt.updatetime = 300 -- time (in ms) to write to swap file +-- buffer +opt.expandtab = true +opt.tabstop = 2 +opt.softtabstop = 2 +opt.autoindent = true +opt.shiftwidth = 2 +-- window +opt.number = true +-- editing +vim.g.mapleader = ',' +vim.g.maplocalleader = ',' +opt.whichwrap = 'b,s,<,>,[,]' +opt.backspace = {'indent', 'eol', 'start'} +opt.list = true +opt.ignorecase = false +opt.hlsearch = true +opt.incsearch = false +opt.inccommand = 'nosplit' +opt.completeopt = {'menuone', 'noselect'} +opt.hidden = true +opt.cursorline = true +opt.ruler = true +opt.colorcolumn = {120} +opt.signcolumn = 'yes' +opt.mouse = 'nv' +cmd('set mousehide') +opt.showmatch = true +opt.cmdheight = 2 +opt.wildmenu = true +opt.wildmode = {'longest', 'full'} +opt.splitright = true +opt.splitbelow = true +opt.shortmess:append('c') + +if not has('gui_running') then + opt.t_Co = 256 +end + +opt.background = 'dark' +if has('termguicolors') then + cmd('let &t_8f = "\\[38;2;%lu;%lu;%lum"') + cmd('let &t_8b = "\\[48;2;%lu;%lu;%lum"') + opt.termguicolors = true +end diff --git a/dot_config/nvim/lua/pack.lua b/dot_config/nvim/lua/pack.lua new file mode 100644 index 0000000..a046a21 --- /dev/null +++ b/dot_config/nvim/lua/pack.lua @@ -0,0 +1,24 @@ +local vim = vim + +vim.cmd 'packadd paq-nvim' +local paq = require'paq-nvim'.paq +paq{'savq/paq-nvim', opt = true} + +-- libraries +paq 'nvim-lua/popup.nvim' +paq 'nvim-lua/plenary.nvim' + +-- files +paq 'tssm/fairyfloss.vim' -- theme +paq 'mhinz/vim-startify' -- startup page +paq 'nvim-telescope/telescope.nvim' -- fuzzy finder +paq 'rmagatti/auto-session' -- auto session +paq 'rmagatti/session-lens' -- session lens for telescope +paq 'crispgm/telescope-heading.nvim' -- markdown heading for telescope + +-- language +paq {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} -- treesitter +paq 'nvim-treesitter/playground' -- ts playground +paq 'nvim-treesitter/nvim-treesitter-textobjects' -- ts textobjects +paq 'neovim/nvim-lspconfig' -- lsp client config +paq 'hrsh7th/nvim-compe' -- completion diff --git a/dot_config/nvim/lua/plugins/compe.lua b/dot_config/nvim/lua/plugins/compe.lua new file mode 100644 index 0000000..9c0e7f8 --- /dev/null +++ b/dot_config/nvim/lua/plugins/compe.lua @@ -0,0 +1,36 @@ +require'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; + buffer = true; + calc = true; + vsnip = true; + nvim_lsp = true; + nvim_lua = true; + spell = true; + tags = true; + snippets_nvim = true; + treesitter = true; + } +} + +local vim = vim +local opts = { + noremap = true, + silent = true, + expr = true, +} +vim.api.nvim_set_keymap('i', '', "compe#confirm('')", opts) +vim.api.nvim_set_keymap('i', '', "compe#close('')", opts) diff --git a/dot_config/nvim/lua/plugins/lspconfig.lua b/dot_config/nvim/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..9870ac0 --- /dev/null +++ b/dot_config/nvim/lua/plugins/lspconfig.lua @@ -0,0 +1 @@ +require('lspconfig').tsserver.setup{} diff --git a/dot_config/nvim/lua/plugins/setups.lua b/dot_config/nvim/lua/plugins/setups.lua new file mode 100644 index 0000000..e5a84cf --- /dev/null +++ b/dot_config/nvim/lua/plugins/setups.lua @@ -0,0 +1,3 @@ +local vim = vim + +vim.api.nvim_command('colorscheme fairyfloss') diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..6a9d5c5 --- /dev/null +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,23 @@ +require('telescope').load_extension('session-lens') +require('telescope').load_extension('heading') + +local set_keymap = require('../common').set_keymap +set_keymap('n', 'ff', 'Telescope find_files') +set_keymap('n', 'fd', 'Telescope git_files') +set_keymap('n', 'fg', 'Telescope live_grep') +set_keymap('n', 'fb', 'Telescope buffers') +set_keymap('n', 'fh', 'Telescope help_tags') +set_keymap('n', 'fl', 'Telescope lsp_document_symbols') +set_keymap('n', 'fk', 'Telescope keymaps') +set_keymap('n', 'fm', 'Telescope heading') + +local actions = require('telescope.actions') +require('telescope').setup{ + defaults = { + mappings = { + i = { + [''] = actions.close + }, + }, + } +} diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..2397e15 --- /dev/null +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,37 @@ +require'nvim-treesitter.configs'.setup { + highlight = { + enable = true + }, + ensure_installed = 'maintained', + indent = { + enable = true + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = 'gnn', + node_incremental = 'grn', + scope_incremental = 'grc', + node_decremental = 'grm' + }, + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false + }, + textobjects = { + select = { + enable = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + ['aP'] = '@parameter.outer', + ['iP'] = '@parameter.inner' + } + } + } +}