dots

my dotfiles
git clone https://tilde.team/~marisa/repo/dots.git
Log | Files | Refs

commit 0e5c113b48219d60109e5cbd331004b600c69d93
parent 83844b58126928cb7030c84f586433dddd6b8f8e
Author: mokou <mokou@fastmail.com>
Date:   Tue,  1 Jun 2021 12:45:47 +0200

add nvim config

Diffstat:
Adot_config/nvim/init.lua | 12++++++++++++
Adot_config/nvim/lua/common.lua | 13+++++++++++++
Adot_config/nvim/lua/options.lua | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adot_config/nvim/lua/pack.lua | 24++++++++++++++++++++++++
Adot_config/nvim/lua/plugins/compe.lua | 36++++++++++++++++++++++++++++++++++++
Adot_config/nvim/lua/plugins/lspconfig.lua | 1+
Adot_config/nvim/lua/plugins/setups.lua | 3+++
Adot_config/nvim/lua/plugins/telescope.lua | 23+++++++++++++++++++++++
Adot_config/nvim/lua/plugins/treesitter.lua | 37+++++++++++++++++++++++++++++++++++++
9 files changed, 208 insertions(+), 0 deletions(-)

diff --git a/dot_config/nvim/init.lua 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 @@ -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 @@ -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 = "\\<Esc>[38;2;%lu;%lu;%lum"') + cmd('let &t_8b = "\\<Esc>[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 @@ -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 @@ -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', '<cr>', "compe#confirm('<CR>')", opts) +vim.api.nvim_set_keymap('i', '<c-c>', "compe#close('<c-c>')", opts) diff --git a/dot_config/nvim/lua/plugins/lspconfig.lua 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 @@ -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 @@ -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', '<leader>ff', '<cmd>Telescope find_files<cr>') +set_keymap('n', '<leader>fd', '<cmd>Telescope git_files<cr>') +set_keymap('n', '<leader>fg', '<cmd>Telescope live_grep<cr>') +set_keymap('n', '<leader>fb', '<cmd>Telescope buffers') +set_keymap('n', '<leader>fh', '<cmd>Telescope help_tags<cr>') +set_keymap('n', '<leader>fl', '<cmd>Telescope lsp_document_symbols<cr>') +set_keymap('n', '<leader>fk', '<cmd>Telescope keymaps<cr>') +set_keymap('n', '<leader>fm', '<cmd>Telescope heading<cr>') + +local actions = require('telescope.actions') +require('telescope').setup{ + defaults = { + mappings = { + i = { + ['<esc>'] = actions.close + }, + }, + } +} diff --git a/dot_config/nvim/lua/plugins/treesitter.lua 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' + } + } + } +}