Skip to content

Commit

Permalink
feat(nvim): improve completion and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
tagoro9 committed Oct 16, 2021
1 parent 9ae63f6 commit ab4abf0
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 12 deletions.
16 changes: 15 additions & 1 deletion config/nvim/lua/general/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,22 @@ map('n', '<leader>pv', ':Vexplore<CR>', options)
map('i', 'jk' , '<ESC>', options)
map('i', 'kj' , '<ESC>', options)

-- Don't use arrow keys in insert mode
-- Don't use arrow keys in insert mode
map('i', '<up>', '<nop>', options)
map('i', '<down>', '<nop>', options)
map('i', '<left>', '<nop>', options)
map('i', '<right>', '<nop>', options)

-- Completion
vim.o.completeopt = "menuone,noinsert,noselect"
vim.o.shortmess = vim.o.shortmess .. "c"

map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})

-- lsp provider to find the cursor word definition and reference
map('n', 'gh', ':lua require("lspsaga.provider").lsp_finder()<CR>', {noremap = true, silent = true})
map('n', '<leader>ca', ':lua require("lspsaga.codeaction").code_action()<CR>', {noremap = true, silent = true})
map('n', 'K', '<cmd>:lua require("lspsaga.hover").render_hover_doc()<CR>', {noremap = true, silent = true})
map('n', '[e', '<cmd>:lua require("lspsaga.diagnostic").lsp_jump_diagnostic_prev()<CR>', {noremap = true, silent = true})
map('n', ']e', '<cmd>:lua require("lspsaga.diagnostic").lsp_jump_diagnostic_next()<CR>', {noremap = true, silent = true})
13 changes: 9 additions & 4 deletions config/nvim/lua/general/sets.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local o = vim.o
local wo = vim.wo
local bo = vim.bo
local g = vim.g

-- global options
o.splitbelow = true
Expand All @@ -12,16 +13,20 @@ o.incsearch = true
o.hlsearch = false
o.hidden = true
o.scrolloff=8
o.completeopt="menuone,noinsert,noselect"
o.completeopt = "menuone,noselect"
o.smartindent = true
o.tabstop = 2
o.softtabstop = 2
o.shiftwidth = 2
-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable delays and poor user experience.
o.updatetime = 50

-- buffer-local options
bo.expandtab = true
bo.smartindent = true
bo.tabstop = 4
bo.softtabstop = 4
bo.shiftwidth = 4
bo.tabstop = 2
bo.softtabstop = 2
bo.shiftwidth = 2

-- window-local options
wo.wrap = false
Expand Down
29 changes: 24 additions & 5 deletions config/nvim/lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,36 @@ local cmd = vim.cmd
cmd 'packadd paq-nvim'
local paq = require('paq-nvim').paq

-- Plugin management
paq{'savq/paq-nvim', opt=true}
paq { 'dracula/vim', as = 'dracula' }

-- telescope
paq { 'nvim-lua/plenary.nvim' }
paq { 'nvim-lua/popup.nvim' }
paq { 'nvim-telescope/telescope.nvim' }
paq 'nvim-telescope/telescope-fzy-native.nvim'

-- lsp and completion
paq { 'kabouzeid/nvim-lspinstall' }
paq { 'neovim/nvim-lspconfig' }
paq { 'hrsh7th/nvim-compe' }
paq { 'glepnir/lspsaga.nvim' }
paq { 'simrat39/symbols-outline.nvim' }

-- tree sitter
paq { 'nvim-treesitter/nvim-treesitter' }
paq { 'nvim-treesitter/playground' }

-- Git
paq { 'tpope/vim-fugitive' }
paq { 'airblade/vim-gitgutter' }

-- Powerline and themes
paq { 'vim-airline/vim-airline' }
paq { 'vim-airline/vim-airline-themes' }
paq { 'tpope/vim-fugitive' }
paq { 'dracula/vim', as = 'dracula' }
paq { 'kyazdani42/nvim-web-devicons' }
paq { 'neovim/nvim-lspconfig' }
paq { 'kabouzeid/nvim-lspinstall' }
paq { 'nvim-lua/completion-nvim' }

-- language formatter
paq { 'sbdchd/neoformat' }

33 changes: 31 additions & 2 deletions config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local on_attach = require'completion'.on_attach
--local on_attach = require'completion'.on_attach

-- config that activates keymaps and enables snippet support
local function make_config()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
capabilities = capabilities,
on_attach = on_attach,
--on_attach = on_attach,
}
end

Expand All @@ -27,3 +27,32 @@ require'lspinstall'.post_install_hook = function ()
setup_servers() -- reload installed servers
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
end

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 = false,
tags = false,
snippets_nvim = true,
treesitter = false
}
}
)

0 comments on commit ab4abf0

Please sign in to comment.