Last active
June 19, 2022 02:48
-
-
Save ryanponce/6b9a213c2eda0c3d318d2bd7246a917b to your computer and use it in GitHub Desktop.
neovim config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 require('gitsigns').setup { | |
| 2 current_line_blame = true, | |
| 3 current_line_blame_opts = { | |
| 4 virt_text_pos = 'right_align' | |
| 5 } | |
| 6 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 require('ryanponce/telescope') | |
| 2 require('ryanponce/lightline') | |
| 3 require('ryanponce/gitsigns') | |
| 4 require('ryanponce/lsp') | |
| 5 require('ryanponce/treesitter') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 syntax on | |
| 2 colorscheme github_dark_default | |
| 3 set termguicolors | |
| 4 set background=dark | |
| 5 set tabstop=2 | |
| 6 set softtabstop=2 | |
| 7 set expandtab | |
| 8 set smartindent | |
| 9 set shiftwidth=2 | |
| 10 set number | |
| 11 set numberwidth=2 | |
| 12 set incsearch | |
| 13 set nohlsearch | |
| 14 set splitbelow | |
| 15 set splitright | |
| 16 set hidden | |
| 17 set undofile | |
| 18 set noshowmode | |
| 19 | |
| 20 lua require('plugins') | |
| 21 lua require('ryanponce') | |
| 22 | |
| 23 let mapleader = ' ' | |
| 24 nnoremap <leader>h :wincmd h<Cr> | |
| 25 nnoremap <leader>j :wincmd j<Cr> | |
| 26 nnoremap <leader>k :wincmd k<Cr> | |
| 27 nnoremap <leader>l :wincmd l<Cr> | |
| 28 nnoremap <C-p> :Telescope find_files<Cr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 vim.g.lightline = { | |
| 2 active = { | |
| 3 left = { | |
| 4 { 'mode', 'past' }, | |
| 5 { 'gitbranch', 'filename', 'modified' } | |
| 6 } | |
| 7 }, | |
| 8 component_function = { | |
| 9 gitbranch = 'fugitive#head' | |
| 10 } | |
| 11 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 -- lspconfig | |
| 2 local nvim_lsp = require('lspconfig') | |
| 3 local servers = { 'tsserver' } | |
| 4 | |
| 5 local on_attach = function(client, bufnr) | |
| 6 local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end | |
| 7 local opts = { noremap=true, silent=true } | |
| 8 | |
| 9 buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) | |
| 10 buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) | |
| 11 buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) | |
| 12 buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) | |
| 13 buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | |
| 14 buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) | |
| 15 buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) | |
| 16 buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) | |
| 17 buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) | |
| 18 buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) | |
| 19 buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) | |
| 20 buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | |
| 21 buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) | |
| 22 buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | |
| 23 buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | |
| 24 buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts) | |
| 25 buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts) | |
| 26 end | |
| 27 | |
| 28 local capabilities = vim.lsp.protocol.make_client_capabilities() | |
| 29 capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) | |
| 30 | |
| 31 local servers = { 'tsserver' } | |
| 32 for _, lsp in ipairs(servers) do | |
| 33 nvim_lsp[lsp].setup { | |
| 34 capabilities = capabilities, | |
| 35 on_attach = on_attach, | |
| 36 } | |
| 37 end | |
| 38 | |
| 39 -- nvim-cmp | |
| 40 local cmp = require('cmp') | |
| 41 local lspkind = require('lspkind') | |
| 42 local luasnip = require('luasnip') | |
| 43 | |
| 44 -- better autocompletion experience | |
| 45 vim.o.completeopt = 'menuone,noselect' | |
| 46 | |
| 47 cmp.setup { | |
| 48 -- Format the autocomplete menu | |
| 49 formatting = { | |
| 50 format = lspkind.cmp_format() | |
| 51 }, | |
| 52 mapping = { | |
| 53 -- Use Tab and shift-Tab to navigate autocomplete menu | |
| 54 ['<Tab>'] = function(fallback) | |
| 55 if cmp.visible() then | |
| 56 cmp.select_next_item() | |
| 57 elseif luasnip.expand_or_jumpable() then | |
| 58 luasnip.expand_or_jump() | |
| 59 else | |
| 60 fallback() | |
| 61 end | |
| 62 end, | |
| 63 ['<S-Tab>'] = function(fallback) | |
| 64 if cmp.visible() then | |
| 65 cmp.select_prev_item() | |
| 66 elseif luasnip.jumpable(-1) then | |
| 67 luasnip.jump(-1) | |
| 68 else | |
| 69 fallback() | |
| 70 end | |
| 71 end, | |
| 72 ['<CR>'] = cmp.mapping.confirm { | |
| 73 behavior = cmp.ConfirmBehavior.Replace, | |
| 74 select = true, | |
| 75 }, | |
| 76 }, | |
| 77 snippet = { | |
| 78 expand = function(args) | |
| 79 luasnip.lsp_expand(args.body) | |
| 80 end | |
| 81 }, | |
| 82 sources = { | |
| 83 { name = 'nvim_lsp' }, | |
| 84 { name = 'luasnip' }, | |
| 85 }, | |
| 86 } | |
| ~ | |
| ~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 return require('packer').startup(function(use) | |
| 2 use 'wbthomason/packer.nvim' | |
| 3 use 'projekt0n/github-nvim-theme' | |
| 4 use { | |
| 5 'nvim-telescope/telescope.nvim', | |
| 6 requires = { {'nvim-lua/plenary.nvim'} } | |
| 7 } | |
| 8 use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } | |
| 9 use 'itchyny/lightline.vim' | |
| 10 use 'tpope/vim-fugitive' | |
| 11 use 'lewis6991/gitsigns.nvim' | |
| 12 use 'neovim/nvim-lspconfig' | |
| 13 use 'hrsh7th/nvim-cmp' | |
| 14 use 'hrsh7th/cmp-nvim-lsp' | |
| 15 use 'L3MON4D3/LuaSnip' | |
| 16 use 'saadparwaiz1/cmp_luasnip' | |
| 17 use 'onsails/lspkind-nvim' | |
| 18 use 'nvim-treesitter/nvim-treesitter' | |
| 19 end) | |
| ~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 local telescope = require('telescope') | |
| 2 | |
| 3 telescope.setup {} | |
| 4 | |
| 5 telescope.load_extension('fzf') | |
| ~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 local treesitter = require('nvim-treesitter.configs') | |
| 2 | |
| 3 treesitter.setup { | |
| 4 highlight = { | |
| 5 enable = true | |
| 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment