Skip to content

Commit

Permalink
feat(treesitter and autopairs): added treesitter and autopairs with t…
Browse files Browse the repository at this point in the history
…heir minimal configs
  • Loading branch information
felicandalc committed May 26, 2022
1 parent 0fb7c12 commit 5654260
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 3 deletions.
2 changes: 2 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ require "nn.colorscheme"
require "nn.cmp"
require "nn.lsp"
require "nn.telescope"
require "nn.treesitter"
require "nn.autopairs"
33 changes: 33 additions & 0 deletions lua/nn/autopairs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- Setup nvim-cmp.
local status_ok, npairs = pcall(require, "nvim-autopairs")
if not status_ok then
return
end

npairs.setup {
check_ts = true,
ts_config = {
lua = { "string", "source" },
javascript = { "string", "template_string" },
java = false,
},
disable_filetype = { "TelescopePrompt", "spectre_panel" },
fast_wrap = {
map = "<M-e>",
chars = { "{", "[", "(", '"', "'" },
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
offset = 0, -- Offset from pattern match
end_key = "$",
keys = "qwertyuiopzxcvbnmasdfghjkl",
check_comma = true,
highlight = "PmenuSel",
highlight_grey = "LineNr",
},
}

local cmp_autopairs = require "nvim-autopairs.completion.cmp"
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })
2 changes: 1 addition & 1 deletion lua/nn/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)

-- Telescope
-- keymap("n", "<leader>f", "<cmd>Telescope find_files<cr>", opts)
keymap("n", "<leader>p", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", opts)
keymap("n", "<c-p>", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", opts)
keymap("n", "<c-t>", "<cmd>Telescope live_grep<cr>", opts)

-- Terminal --
Expand Down
1 change: 0 additions & 1 deletion lua/nn/lsp/settings/jsonls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,3 @@ local opts = {
}

return opts

9 changes: 8 additions & 1 deletion lua/nn/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ return packer.startup(function(use)
use "nvim-lua/plenary.nvim" -- Useful lua functions used ny lots of plugins
use "tpope/vim-endwise" -- Help to end certain structures automatically
use {'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', cmd = 'MarkdownPreview'} -- Live preview markdown on browser
use "windwp/nvim-autopairs" -- Autopairs, integrates with both cmp and treesitter

-- CMP
use "hrsh7th/nvim-cmp"
Expand All @@ -66,12 +67,18 @@ return packer.startup(function(use)

-- LSP
use "neovim/nvim-lspconfig"
use "williamboman/nvim-lsp-installer"
use "williamboman/nvim-lsp-installer"

-- Telescope
use "nvim-telescope/telescope.nvim"
use 'nvim-telescope/telescope-media-files.nvim'

-- Treesitter
use {
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
}

-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if PACKER_BOOTSTRAP then
Expand Down
17 changes: 17 additions & 0 deletions lua/nn/treesitter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end

configs.setup {
ensure_installed = "all",
sync_install = false,
ignore_install = { "" }, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled
additional_vim_regex_highlighting = true,

},
indent = { enable = true, disable = { "yaml" } },
}
10 changes: 10 additions & 0 deletions plugin/packer_compiled.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ _G.packer_plugins = {
path = "/home/nn/.local/share/nvim/site/pack/packer/opt/markdown-preview.nvim",
url = "https://github.com/iamcco/markdown-preview.nvim"
},
["nvim-autopairs"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
url = "https://github.com/windwp/nvim-autopairs"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/nvim-cmp",
Expand All @@ -142,6 +147,11 @@ _G.packer_plugins = {
path = "/home/nn/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["packer.nvim"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/packer.nvim",
Expand Down

0 comments on commit 5654260

Please sign in to comment.