瀏覽代碼

Merge branch 'frigg' of cmte/dotfiles into master

cmte 2 年之前
父節點
當前提交
e4a23dcd25
共有 11 個文件被更改,包括 293 次插入138 次删除
  1. 7 0
      bash/bashrc
  2. 2 0
      bash/environment
  3. 3 0
      git/gitconfig
  4. 1 0
      nvim/.gitignore
  5. 141 0
      nvim/after/plugin/barbar.lua
  6. 40 45
      nvim/after/plugin/lsp.lua
  7. 9 0
      nvim/after/plugin/telescope.lua
  8. 19 0
      nvim/after/plugin/treesitter.lua
  9. 64 0
      nvim/init.lua
  10. 0 90
      nvim/init.vim
  11. 7 3
      nvim/main.sh

+ 7 - 0
bash/bashrc

@@ -32,3 +32,10 @@ export MOZ_X11_EGL=1
 
 
 export PATH=$PATH:/home/cmte/bin
+
+export NVM_DIR="$HOME/.nvm"
+[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
+[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
+
+eval $(ssh-agent) > /dev/null
+ssh-add -q $HOME/.ssh/github > /dev/null

+ 2 - 0
bash/environment

@@ -13,6 +13,8 @@ LC_MEASUREMENT="en_US.UTF-8"; export LC_MEASUREMENT
 LC_IDENTIFICATION="en_US.UTF-8"; export LC_IDENTIFICATION
 LC_ALL=; export LC_ALL
 
+TERM=xterm-256color; export TERM
+
 # Terminal settings
 test -e /usr/local/bin/nvim && EDITOR=nvim || EDITOR=nano
 export EDITOR

+ 3 - 0
git/gitconfig

@@ -1,3 +1,6 @@
 [user]
 	email = andreani.dr@gmail.com
 	name = Douglas A
+
+[init]
+    defaultBranch = main

+ 1 - 0
nvim/.gitignore

@@ -0,0 +1 @@
+plugged

+ 141 - 0
nvim/after/plugin/barbar.lua

@@ -0,0 +1,141 @@
+local map = vim.api.nvim_set_keymap
+local opts = { noremap = true, silent = true }
+
+-- Move to previous/next
+map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts)
+map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts)
+-- Re-order to previous/next
+map('n', '<A-<>', '<Cmd>BufferMovePrevious<CR>', opts)
+map('n', '<A->>', '<Cmd>BufferMoveNext<CR>', opts)
+-- Goto buffer in position...
+map('n', '<A-1>', '<Cmd>BufferGoto 1<CR>', opts)
+map('n', '<A-2>', '<Cmd>BufferGoto 2<CR>', opts)
+map('n', '<A-3>', '<Cmd>BufferGoto 3<CR>', opts)
+map('n', '<A-4>', '<Cmd>BufferGoto 4<CR>', opts)
+map('n', '<A-5>', '<Cmd>BufferGoto 5<CR>', opts)
+map('n', '<A-6>', '<Cmd>BufferGoto 6<CR>', opts)
+map('n', '<A-7>', '<Cmd>BufferGoto 7<CR>', opts)
+map('n', '<A-8>', '<Cmd>BufferGoto 8<CR>', opts)
+map('n', '<A-9>', '<Cmd>BufferGoto 9<CR>', opts)
+map('n', '<A-0>', '<Cmd>BufferLast<CR>', opts)
+-- Pin/unpin buffer
+map('n', '<A-p>', '<Cmd>BufferPin<CR>', opts)
+-- Close buffer
+map('n', '<A-c>', '<Cmd>BufferClose<CR>', opts)
+-- Wipeout buffer
+--                 :BufferWipeout
+-- Close commands
+--                 :BufferCloseAllButCurrent
+--                 :BufferCloseAllButPinned
+--                 :BufferCloseAllButCurrentOrPinned
+--                 :BufferCloseBuffersLeft
+--                 :BufferCloseBuffersRight
+-- Magic buffer-picking mode
+map('n', '<C-p>', '<Cmd>BufferPick<CR>', opts)
+-- Sort automatically by...
+map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts)
+map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', opts)
+map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', opts)
+map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts)
+
+-- Other:
+-- :BarbarEnable - enables barbar (enabled by default)
+-- :BarbarDisable - very bad command, should never be used
+--
+-- Set barbar's options
+require'bufferline'.setup {
+  -- Enable/disable animations
+  animation = true,
+
+  -- Enable/disable auto-hiding the tab bar when there is a single buffer
+  auto_hide = false,
+
+  -- Enable/disable current/total tabpages indicator (top right corner)
+  tabpages = true,
+
+  -- Enable/disable close button
+  closable = true,
+
+  -- Enables/disable clickable tabs
+  --  - left-click: go to buffer
+  --  - middle-click: delete buffer
+  clickable = true,
+
+  -- Enables / disables diagnostic symbols
+  diagnostics = {
+    -- you can use a list
+    {enabled = true, icon = 'ff'}, -- ERROR
+    {enabled = false}, -- WARN
+    {enabled = false}, -- INFO
+    {enabled = true},  -- HINT
+
+    -- OR `vim.diagnostic.severity`
+    [vim.diagnostic.severity.ERROR] = {enabled = true, icon = 'ff'},
+    [vim.diagnostic.severity.WARN] = {enabled = false},
+    [vim.diagnostic.severity.INFO] = {enabled = false},
+    [vim.diagnostic.severity.HINT] = {enabled = true},
+  },
+
+  -- Excludes buffers from the tabline
+  exclude_ft = {'javascript'},
+  exclude_name = {'package.json'},
+
+  -- Hide inactive buffers and file extensions. Other options are `alternate`, `current`, and `visible`.
+  hide = {extensions = true, inactive = true},
+
+  -- Disable highlighting alternate buffers
+  highlight_alternate = false,
+
+  -- Disable highlighting file icons in inactive buffers
+  highlight_inactive_file_icons = false,
+
+  -- Enable highlighting visible buffers
+  highlight_visible = true,
+
+  -- Enable/disable icons
+  -- if set to 'numbers', will show buffer index in the tabline
+  -- if set to 'both', will show buffer index and icons in the tabline
+  icons = false,
+
+  -- If set, the icon color will follow its corresponding buffer
+  -- highlight group. By default, the Buffer*Icon group is linked to the
+  -- Buffer* group (see Highlighting below). Otherwise, it will take its
+  -- default value as defined by devicons.
+  icon_custom_colors = false,
+
+  -- Configure icons on the bufferline.
+  icon_separator_active = '▎',
+  icon_separator_inactive = '▎',
+  icon_close_tab = '',
+  icon_close_tab_modified = '●',
+  icon_pinned = '車',
+
+  -- If true, new buffers will be inserted at the start/end of the list.
+  -- Default is to insert after current buffer.
+  insert_at_end = false,
+  insert_at_start = false,
+
+  -- Sets the maximum padding width with which to surround each tab
+  maximum_padding = 1,
+
+  -- Sets the minimum padding width with which to surround each tab
+  minimum_padding = 1,
+
+  -- Sets the maximum buffer name length.
+  maximum_length = 30,
+
+  -- If set, the letters for each buffer in buffer-pick mode will be
+  -- assigned based on their name. Otherwise or in case all letters are
+  -- already assigned, the behavior is to assign letters in order of
+  -- usability (see order below)
+  semantic_letters = true,
+
+  -- New buffer letters are assigned in this order. This order is
+  -- optimal for the qwerty keyboard layout but might need adjustement
+  -- for other layouts.
+  letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP',
+
+  -- Sets the name of unnamed buffers. By default format is "[Buffer X]"
+  -- where X is the buffer number. But only a static string is accepted here.
+  no_name_title = nil,
+}

+ 40 - 45
nvim/lua/init.lua → nvim/after/plugin/lsp.lua

@@ -1,36 +1,39 @@
---Set highlight on search
-vim.o.hlsearch = false
-
---Set statusbar
-vim.g.lightline = {
-        colorscheme = 'onedark',
-        active = { left = { { 'mode', 'paste' }, { 'gitbranch', 'readonly', 'filename', 'modified' } } },
-        component_function = { gitbranch = 'fugitive#head' },
-}
-
--- Highlight on yank
-vim.api.nvim_exec(
-[[
-        augroup YankHighlight
-        autocmd!
-        autocmd TextYankPost * silent! lua vim.highlight.on_yank()
-        augroup end
-]],
-false
-)
-
-local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
+local lsp = require('lsp-zero')
+lsp.preset('recommended')
+
+lsp.ensure_installed({
+	'tsserver',
+	'eslint',
+    'lua_ls',
+	'gopls',
+	'rust_analyzer',
+	'clangd'
+})
+
+
+-- Fix Undefined global 'vim'
+lsp.configure('lua_ls', {
+    settings = {
+        Lua = {
+            diagnostics = {
+                globals = { 'vim' }
+            }
+        }
+    }
+})
+
+
 local cmp = require'cmp'
+local cmp_select = {behavior = cmp.SelectBehavior.Select}
 
 cmp.setup({
         mapping = {
                 ["<C-e>"] = cmp.mapping.close(),
-                ["<C-p>"] = cmp.mapping.select_prev_item(),
-                ["<C-n>"] = cmp.mapping.select_next_item(),
+                ["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
+                ["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
                 ["<C-d>"] = cmp.mapping.scroll_docs(-4),
                 ["<C-f>"] = cmp.mapping.scroll_docs(4),
                 ["<C-y>"] = cmp.mapping.confirm {
-                        behavior = cmp.ConfirmBehavior.Insert,
                         select = true,
                 },
                 ["<C-space>"] = cmp.mapping.complete(),
@@ -47,9 +50,9 @@ cmp.setup({
         },
 
         snippet = {
-                expand = function(args) 
+                expand = function(args)
                         require('luasnip').lsp_expand(args.body)
-                end,      
+                end,
         },
 
         experimental = {
@@ -57,15 +60,11 @@ cmp.setup({
         }
 })
 
+
 local opts = { noremap=true, silent=true }
-vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
-vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
-vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
-vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
 
-local on_attach = function(client, bufnr)
-  -- Enable completion triggered by <c-x><c-o>
-  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
+lsp.on_attach(function(client, bufnr)
+	  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
 
   -- Mappings.
   -- See `:help vim.lsp.*` for documentation on any of the below functions
@@ -82,16 +81,12 @@ local on_attach = function(client, bufnr)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
-end
+
+  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
+
+end)
+
+
+lsp.setup()
 
 
-local servers = { 'gopls', 'clangd', 'jedi_language_server' , 'rust_analyzer', 'tsserver' }
-for _, lsp in pairs(servers) do
-  require('lspconfig')[lsp].setup {
-    on_attach = on_attach,
-    flags = {
-      -- This will be the default in neovim 0.7+
-      debounce_text_changes = 150,
-    }
-  }
-end

+ 9 - 0
nvim/after/plugin/telescope.lua

@@ -0,0 +1,9 @@
+local builtin = require('telescope.builtin')
+
+
+vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
+vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
+vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
+vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
+
+

+ 19 - 0
nvim/after/plugin/treesitter.lua

@@ -0,0 +1,19 @@
+require'nvim-treesitter.configs'.setup {
+  -- A list of parser names, or "all"
+  ensure_installed = { "c", "lua", "rust", "javascript", "typescript", "python", "bash" },
+
+  -- Install parsers synchronously (only applied to `ensure_installed`)
+  sync_install = false,
+
+  -- Automatically install missing parsers when entering buffer
+  -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
+  auto_install = true,
+
+
+  highlight = {
+    -- `false` will disable the whole extension
+    enable = true,
+
+    additional_vim_regex_highlighting = false,
+  },
+}

+ 64 - 0
nvim/init.lua

@@ -0,0 +1,64 @@
+vim.g.mapleader = " "
+
+vim.opt.nu = true
+vim.opt.relativenumber = true
+
+vim.opt.tabstop = 4
+vim.opt.softtabstop = 4
+vim.opt.shiftwidth = 4
+vim.opt.expandtab = true
+vim.opt.smartindent = true
+
+vim.opt.wrap = false
+
+vim.opt.swapfile = false
+vim.opt.backup = false
+vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
+vim.opt.undofile = true
+
+vim.opt.hlsearch = false
+vim.opt.incsearch = true
+
+vim.opt.termguicolors = true
+
+vim.opt.scrolloff = 8
+vim.opt.signcolumn = "yes"
+vim.opt.isfname:append("@-@")
+
+vim.opt.updatetime = 50
+
+vim.opt.colorcolumn = "80"
+
+local Plug = vim.fn['plug#']
+
+vim.call('plug#begin', '~/.config/nvim/plugged')
+
+Plug 'nvim-lua/plenary.nvim'
+Plug 'nvim-telescope/telescope.nvim'
+Plug 'marko-cerovac/material.nvim'
+Plug('nvim-treesitter/nvim-treesitter', {['do'] = 'TSUpdate'})
+
+Plug 'neovim/nvim-lspconfig'
+Plug 'williamboman/mason.nvim'
+Plug 'williamboman/mason-lspconfig.nvim'
+
+Plug 'hrsh7th/nvim-cmp'
+Plug 'hrsh7th/cmp-buffer'
+Plug 'hrsh7th/cmp-path'
+Plug 'saadparwaiz1/cmp_luasnip'
+Plug 'hrsh7th/cmp-nvim-lsp'
+Plug 'hrsh7th/cmp-nvim-lua'
+
+Plug 'L3MON4D3/LuaSnip'
+Plug 'rafamadriz/friendly-snippets'
+
+Plug 'VonHeikemen/lsp-zero.nvim'
+Plug 'nvim-tree/nvim-web-devicons'
+
+vim.call('plug#end')
+
+vim.g.material_style = "palenight"
+vim.cmd "colorscheme material"
+
+
+

+ 0 - 90
nvim/init.vim

@@ -1,90 +0,0 @@
-syntax on
-filetype plugin indent on
-
-
-let mapleader = " "
-
-" Plugins
-call plug#begin('~/.vim/plugged')
-	
-	Plug 'neovim/nvim-lspconfig'
-
-	Plug 'neovim/nvim-lspconfig'
-    Plug 'hrsh7th/cmp-nvim-lsp'
-	Plug 'hrsh7th/cmp-buffer'
-	Plug 'hrsh7th/cmp-path'
-	Plug 'hrsh7th/cmp-cmdline'
-
-	" For vsnip users.
-    Plug 'L3MON4D3/LuaSnip'
-	Plug 'hrsh7th/nvim-cmp'
-    Plug 'hrsh7th/cmp-buffer'
-    Plug 'hrsh7th/cmp-path'
-    Plug 'hrsh7th/cmp-nvim-lua'
-    Plug 'hrsh7th/cmp-nvim-lsp'
-    Plug 'saadparwaiz1/cmp_luasnip'
-	""Plug 'hrsh7th/vim-vsnip'
-
-    Plug 'chriskempson/base16-vim'
-	Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}  " We recommend updating the parsers on update
-	Plug 'kaicataldo/material.vim', { 'branch': 'main' }
-    Plug 'nvim-lua/popup.nvim'
-    Plug 'nvim-lua/plenary.nvim'
-    Plug 'nvim-telescope/telescope.nvim'
-    Plug 'itchyny/lightline.vim'
-    Plug 'joshdick/onedark.vim'
-
-    Plug 'rust-lang/rust.vim'
-
-
-call plug#end()
-
-lua require('init')
-" General vim configurations
-set relativenumber
-set colorcolumn=80
-set updatetime=50
-set tabstop=4 softtabstop=4
-set expandtab
-set smartindent
-set completeopt=menu,menuone,noselect
-set noswapfile
-set nobackup
-set scrolloff=8
-set signcolumn=yes
-set nowrap
-set nu
-set hidden
-set undodir=~/.config/nvim/undodir
-set undofile
-
-
-"  Theme settings
-"  https://github.com/kaicataldo/material.vim
-if (has('termguicolors'))
-  set termguicolors
-endif
-let g:material_theme_style = 'darker'
-colorscheme material
-
-
-" Lsp configuration for multiple languages
-
-
-" Use <Tab> and <S-Tab> to navigate through popup menu
-"inoremap <expr> <Tab>   pumvisible() ? "\<C-n>" : "\<Tab>"
-"inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
-
-" Tree-sitter config
-lua require'nvim-treesitter.configs'.setup { highlight = { enable = true }, incremental_selection = { enable = true }, textobjects = { enable = true }}
-
-" keyboard shortcut options
-nnoremap <leader>n gt
-nnoremap <leader>m gT
-
-" Telescope shortcuts
-nnoremap <leader>ff <cmd>Telescope find_files<cr>
-nnoremap <leader>fg <cmd>Telescope live_grep<cr>
-nnoremap <leader>fb <cmd>Telescope buffers<cr>
-nnoremap <leader>fh <cmd>Telescope help_tags<cr>
-

+ 7 - 3
nvim/main.sh

@@ -9,6 +9,10 @@ test -d $LOCAL || mkdir -p $LOCAL
 
 rm $LOCAL/init.vim 2>&1 > /dev/null
 rm $LOCAL/lua/init.lua 2>&1 > /dev/null
-ln -s $DOTFILES/nvim/init.vim $LOCAL/init.vim
-mkdir -p $LOCAL/lua
-ln -s $DOTFILES/nvim/lua/init.lua $LOCAL/lua/init.lua
+ln -s $DOTFILES/nvim/init.lua $LOCAL/init.lua
+mkdir -p $LOCAL/after/plugin
+
+cp -s $DOTFILES/nvim/after/plugin/lsp.lua $LOCAL/after/plugin/lsp.lua
+cp -s $DOTFILES/nvim/after/plugin/telescope.lua $LOCAL/after/plugin/telescope.lua
+cp -s $DOTFILES/nvim/after/plugin/treesitter.lua $LOCAL/after/plugin/treesitter.lua
+