Skip to content

Commit

Permalink
Get treesitter working
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanpinn committed Aug 12, 2024
1 parent ea69c59 commit e9000c4
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 54 deletions.
2 changes: 1 addition & 1 deletion homebrew/personal.Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ brew "mas"
# Polyglot runtime manager (asdf rust clone)
brew "mise"
# Ambitious Vim-fork focused on extensibility and agility
brew "neovim", args: ["HEAD"]
brew "neovim"
# Search tool like grep and The Silver Searcher
brew "ripgrep"
# Static analysis and lint tool, for (ba)sh scripts
Expand Down
24 changes: 12 additions & 12 deletions nvim/after/plugin/conform.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local options = {
formatters_by_ft = {
lua = { "stylua" },
typescript = { { "prettierd", "prettier" }, "eslint_d" },
},
}

require("conform").setup(options)

-- This should be okay to set globally, as will default back to the LSP
-- formatexpr if present and then to nothing.
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
-- local options = {
-- formatters_by_ft = {
-- lua = { "stylua" },
-- typescript = { { "prettierd", "prettier" }, "eslint_d" },
-- },
-- }
--
-- require("conform").setup(options)
--
-- -- This should be okay to set globally, as will default back to the LSP
-- -- formatexpr if present and then to nothing.
-- vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
22 changes: 11 additions & 11 deletions nvim/after/plugin/lint.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require("lint").linters_by_ft = {
lua = { "luacheck" },
typescript = { "eslint" },
}

-- This will run the linters on save.
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})
-- require("lint").linters_by_ft = {
-- lua = { "luacheck" },
-- typescript = { "eslint" },
-- }
--
-- -- This will run the linters on save.
-- vim.api.nvim_create_autocmd({ "BufWritePost" }, {
-- callback = function()
-- require("lint").try_lint()
-- end,
-- })
50 changes: 25 additions & 25 deletions nvim/after/plugin/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
local ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")
if not ok then
return
end
treesitter_configs.setup({
-- A list of parser names, or "all"
ensure_installed = { "lua" },

-- 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 = {
enable = true,

-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
})
-- local ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")
-- if not ok then
-- return
-- end
-- treesitter_configs.setup({
-- -- A list of parser names, or "all"
-- ensure_installed = { "lua" },
--
-- -- 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 = {
-- enable = true,
--
-- -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- -- Using this option may slow down your editor, and you may see some duplicate highlights.
-- -- Instead of true it can also be a list of languages
-- additional_vim_regex_highlighting = false,
-- },
-- })
1 change: 1 addition & 0 deletions nvim/lua/dcp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ require("dcp.set-background")
require("dcp.keymaps")
require("dcp.options")
require("dcp.lsp")
require("dcp.treesitter")
10 changes: 5 additions & 5 deletions nvim/lua/dcp/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Create an event handler for the FileType autocommand
vim.api.nvim_create_autocmd("FileType", {
-- This handler will fire when the buffer's 'filetype' is "python"
-- This handler will fire when the buffer's 'filetype' is "lua"
pattern = "lua",
callback = function(_args)
vim.lsp.start({
Expand Down Expand Up @@ -86,10 +86,10 @@ vim.api.nvim_create_autocmd("LspAttach", {

if client.supports_method("textDocument/formatting") then
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
-- Enable signs
signs = true,
})
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
-- Enable signs
signs = true,
})
end
end,
})
16 changes: 16 additions & 0 deletions nvim/lua/dcp/treesitter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
vim.opt.runtimepath:append(
vim.fs.joinpath(
vim.fn.stdpath("data") --[[@as string]],
"rocks",
"lib",
"luarocks",
"rocks-5.1",
"tree-sitter-*",
"*"
)
)
vim.api.nvim_create_autocmd("FileType", {
callback = function()
pcall(vim.treesitter.start)
end,
})

0 comments on commit e9000c4

Please sign in to comment.