Skip to content

Commit

Permalink
fix: lsp, treesitter and cmp setup
Browse files Browse the repository at this point in the history
  • Loading branch information
arsham committed Dec 18, 2021
1 parent 0c24f82 commit 3e8c2c1
Show file tree
Hide file tree
Showing 9 changed files with 476 additions and 393 deletions.
368 changes: 212 additions & 156 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lua/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ end}

command{"InstallDependencies", function()
local commands = {
fixjson = {"npm", "-g", "install", "--prefix", "~/.node_modules", "fixjson@latest"},
prettier = {"npm", "-g", "install", "--prefix", "~/.node_modules", "prettier@latest"},
golangci = {"go", "install", "github.com/golangci/golangci-lint/cmd/[email protected]"},
gojq = {"go", "install", "github.com/itchyny/gojq/cmd/gojq@latest"},
stylua = {'cargo', 'install', 'stylua'},
fixjson = {"npm", "-g", "install", "--prefix", "~/.node_modules", "fixjson@latest"},
prettier = {"npm", "-g", "install", "--prefix", "~/.node_modules", "prettier@latest"},
neovim = {"npm", "-g", "install", "--prefix", "~/.node_modules", "neovim@latest"},
}

local total = table.length(commands)
Expand Down Expand Up @@ -69,7 +69,7 @@ command{"InstallDependencies", function()

count = count + 1
if count == total then
local str = "yay -S ripgrep bat ccls words-insane ctags"
local str = "yay -S ripgrep bat ccls words-insane ctags python-pip the_silver_searcher"
vim.schedule(function()
vim.fn.setreg('+', str)
end)
Expand Down
118 changes: 60 additions & 58 deletions lua/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ augroup PACKER_RELOAD
augroup END
]]

local lspFiletypes = {
'go',
'lua',
'vim',
'sql',
'bash',
'py',
local status_plugin = 'feline'
local colorizer_ft = {
'css',
'scss',
'sass',
'html',
'yaml',
'json',
'js',
'lua',
'markdown',
}

local status_plugin = 'feline'
Expand All @@ -39,9 +36,11 @@ require('packer').startup({
-- }}}

-- {{{ Core/System utilities
use 'junegunn/fzf'

use {
'junegunn/fzf.vim',
requires = { 'junegunn/fzf' },
requires = 'junegunn/fzf',
config = function() require('settings.fzf') end,
}

Expand Down Expand Up @@ -96,21 +95,21 @@ require('packer').startup({

use {
'tpope/vim-rhubarb',
requires = { 'tpope/vim-fugitive' },
event = { 'BufRead', 'BufNewFile' },
requires = 'tpope/vim-fugitive',
after = 'vim-fugitive',
}

use {
'lewis6991/gitsigns.nvim',
requires = { 'nvim-lua/plenary.nvim' },
requires = 'nvim-lua/plenary.nvim',
config = function() require('settings.gitsigns') end,
event = { 'BufNewFile', 'BufRead' },
}

use {
-- create ~/.gist-vim with this content: token xxxxx
'mattn/vim-gist',
requires = { 'mattn/webapi-vim' },
requires = 'mattn/webapi-vim',
config = function() vim.g.gist_per_page_limit = 100 end,
cmd = { 'Gist' },
}
Expand Down Expand Up @@ -144,17 +143,17 @@ require('packer').startup({
use {
'norcalli/nvim-colorizer.lua',
config = function()
require'colorizer'.setup{ 'css', 'scss', 'sass', 'html', 'lua' }
require'colorizer'.setup(colorizer_ft)
end,
event = { 'BufRead', 'BufNewFile' },
ft = colorizer_ft,
}

use {
'rcarriga/nvim-notify',
config = function()
local async_load_plugin = nil
async_load_plugin = vim.loop.new_async(vim.schedule_wrap(function()
vim.notify = require("notify")
vim.notify = require('notify')
async_load_plugin:close()
end))
async_load_plugin:send()
Expand All @@ -166,7 +165,7 @@ require('packer').startup({
use {
'lukas-reineke/indent-blankline.nvim',
config = function()
require("indent_blankline").setup {
require('indent_blankline').setup {
show_trailing_blankline_indent = false,
show_first_indent_level = false,
}
Expand All @@ -188,12 +187,6 @@ require('packer').startup({
-- }}}

-- {{{ Editing
use {
'numToStr/Comment.nvim',
config = function() require('Comment').setup() end,
event = { 'BufRead', 'BufNewFile' },
}

use {
'tpope/vim-repeat',
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
Expand All @@ -216,7 +209,7 @@ require('packer').startup({
-- Title-Dash/Title-Kebab: gsK
-- dot.case: gs.
'arthurxavierx/vim-caser',
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
keys = { 'gs' },
}

use {
Expand All @@ -232,7 +225,7 @@ require('packer').startup({
'mg979/vim-visual-multi',
branch = 'master',
config = function() require('settings').visual_multi() end,
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
keys = { '<C-n>', '<C-Down>', '<C-Up>' },
}

use {
Expand All @@ -242,15 +235,15 @@ require('packer').startup({

use {
'windwp/nvim-autopairs',
wants = "nvim-cmp",
wants = 'nvim-cmp',
config = function() require('settings').autopairs() end,
event = { 'InsertEnter' },
}

use {
'sQVe/sort.nvim',
config = function()
require("sort").setup({
require('sort').setup({
delimiters = {
',', '|', ';', ':',
's', -- Space
Expand All @@ -265,7 +258,7 @@ require('packer').startup({
-- {{{ Programming
use {
'neovim/nvim-lspconfig',
wants = {'nvim-cmp'},
after = {'nvim-cmp'},
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
}

Expand All @@ -275,48 +268,45 @@ require('packer').startup({
require('settings').lsp_installer()
require('settings.lsp')
end,
wants = {
after = {
'nvim-lspconfig',
'nvim-cmp',
'cmp-nvim-lsp',
'lsp-status.nvim',
'cmp-nvim-lsp',
},
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
}

use {
'hrsh7th/nvim-cmp',
config = function() require('settings.cmp') end,
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
event = { 'BufRead', 'BufNewFile', 'InsertEnter' },
requires = {
{ 'hrsh7th/cmp-nvim-lsp' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lua' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-buffer' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-path' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-cmdline' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-calc' , after = 'nvim-cmp' },
{ "lukas-reineke/cmp-rg" , after = 'nvim-cmp' },
-- { 'hrsh7th/cmp-copilot' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lsp-signature-help' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-vsnip' , after = 'nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' },
{ 'hrsh7th/cmp-buffer', after = 'nvim-cmp' },
{ 'hrsh7th/cmp-path', after = 'nvim-cmp' },
{ 'hrsh7th/cmp-cmdline', after = 'nvim-cmp' },
{ 'hrsh7th/cmp-calc', after = 'nvim-cmp' },
{ 'lukas-reineke/cmp-rg', after = 'nvim-cmp' },
{ 'hrsh7th/cmp-vsnip', after = 'nvim-cmp' },
{ 'hrsh7th/vim-vsnip',
config = function ()
vim.g.vsnip_snippet_dir = vim.env.HOME .. "/.config/nvim/vsnip"
vim.g.vsnip_snippet_dir = vim.env.HOME .. '/.config/nvim/vsnip'
end,
after = 'nvim-cmp',
after = 'nvim-cmp',
requires = 'rafamadriz/friendly-snippets',
},
}
}

use {
'dense-analysis/ale',
config = function() require('settings.ale') end, opt = true,
ft = lspFiletypes,
{ 'hrsh7th/cmp-nvim-lsp-signature-help', after = 'nvim-cmp' },
},
config = function() require('settings.cmp') end,
}

use {
'ojroques/nvim-lspfuzzy',
requires = {
{ 'junegunn/fzf' },
{ 'junegunn/fzf.vim' },
'junegunn/fzf',
'junegunn/fzf.vim',
'nvim-lspconfig',
},
config = function()
require('lspfuzzy').setup{
Expand All @@ -325,14 +315,22 @@ require('packer').startup({
},
}
end,
after = {"nvim-lspconfig", "fzf.vim"},
after = {'nvim-lspconfig', 'fzf.vim'},
}

use {
'jose-elias-alvarez/null-ls.nvim',
requires = { 'nvim-lua/plenary.nvim' },
requires = {
'nvim-lua/plenary.nvim',
'nvim-lspconfig',
},
after = { 'nvim-lspconfig' },
config = function() require('settings').null_ls() end,
ft = lspFiletypes,
}

use {
'nvim-lua/lsp-status.nvim',
after = {'nvim-lspconfig', 'fzf.vim'},
}

use {
Expand Down Expand Up @@ -387,6 +385,10 @@ require('packer').startup({

use {
'nanotee/sqls.nvim',
config = function ()
vim.keymap.nnoremap{'<C-Space>', ':SqlsExecuteQuery<CR>', buffer=true, silent=true}
vim.keymap.vnoremap{'<C-Space>', ':SqlsExecuteQuery<CR>', buffer=true, silent=true}
end,
ft = { 'sql' },
}

Expand Down
34 changes: 0 additions & 34 deletions lua/settings/ale.lua

This file was deleted.

17 changes: 14 additions & 3 deletions lua/settings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@ end

function M.autopairs()
local autopairs = require('nvim-autopairs')
local ts_conds = require('nvim-autopairs.ts-conds')
local Rule = require('nvim-autopairs.rule')
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
autopairs.setup{
autopairs = {enable = true}
-- autopairs = {enable = true},
check_ts = true,
}

local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
-- press % => %% only while inside a comment or string
autopairs.add_rules({
Rule("%", "%", "lua")
:with_pair(ts_conds.is_ts_node({'string','comment'})),
Rule("$", "$", "lua")
:with_pair(ts_conds.is_not_ts_node({'function'}))
})

cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
end

Expand Down
Loading

0 comments on commit 3e8c2c1

Please sign in to comment.