Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
install \
install-brew \
install-git \
install-nvim \
install-nvim-tree-sitter \
install-sh \
install-tmux \
install-vim \
Expand Down Expand Up @@ -104,10 +106,16 @@ install-npm:
cp -pR -- npm/npmrc $(XDG_CONFIG_HOME)/npm/npmrc
cp -p -- npm/profile.d/* $(HOME)/.profile.d/

install-nvim: lint-lua
install-nvim: lint-lua install-nvim-tree-sitter
mkdir -p -- $(XDG_CONFIG_HOME)/nvim
cp -pR -- nvim/ $(XDG_CONFIG_HOME)/nvim/

# NOTE: Requires luarocks to be installed.
install-nvim-tree-sitter:
luarocks --force-lock --lua-version=5.1 --tree=$(XDG_DATA_HOME)/nvim/rocks --dev install tree-sitter-lua
luarocks --force-lock --lua-version=5.1 --tree=$(XDG_DATA_HOME)/nvim/rocks --dev install tree-sitter-vimdoc
luarocks --force-lock --lua-version=5.1 --tree=$(XDG_DATA_HOME)/nvim/rocks --dev install tree-sitter-markdown

install-sh: lint-sh
cp -p -- sh/profile $(HOME)/.profile
mkdir -p -- $(HOME)/.profile.d/
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# .dotfiles

My dotfiles, managed with `make`.

## Neovim

### Install Treesitter stuff

```sh
luarocks --force-lock --lua-version=5.1 --tree=$HOME/.local/share/nvim/rocks --dev install tree-sitter-*
```
2 changes: 2 additions & 0 deletions homebrew/personal.Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ brew "jq"
brew "lua-language-server"
# Tool for linting and static analysis of Lua code
brew "luacheck"
# Package manager for the Lua programming language
brew "luarocks"
# Macro processing language
brew "m4", link: true
# Mac App Store command-line interface
Expand Down
14 changes: 13 additions & 1 deletion nvim/after/ftplugin/lua.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
-- Tabs should have 4 space width.
vim.opt_local.tabstop = 4

-- Use luacheck as compiler for sh files.
-- Use luacheck as compiler for lua files.
vim.cmd([[compiler luacheck]])

-- Show line numbers by default.
vim.o.number = true

-- Enable treesitter for syntax highlighting.
pcall(vim.treesitter.start)

-- Enable treesitter for folding.
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldmethod = "expr"
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
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,
-- })
136 changes: 68 additions & 68 deletions nvim/after/plugin/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
-- Setup language servers.
local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup({
on_init = function(client)
local path = client.workspace_folders[1].name
if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
return
end

client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
},
})
end,
settings = {
Lua = {},
},
})
lspconfig.tsserver.setup({})

-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set("n", "<localleader>e", vim.diagnostic.open_float)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "<localleader>q", vim.diagnostic.setloclist)

-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"

-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<localleader>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<localleader>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<localleader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set("n", "<localleader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<localleader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set({ "n", "v" }, "<localleader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
end,
})
-- local lspconfig = require("lspconfig")
-- lspconfig.lua_ls.setup({
-- on_init = function(client)
-- local path = client.workspace_folders[1].name
-- if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
-- return
-- end
--
-- client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
-- runtime = {
-- -- Tell the language server which version of Lua you're using
-- -- (most likely LuaJIT in the case of Neovim)
-- version = "LuaJIT",
-- },
-- -- Make the server aware of Neovim runtime files
-- workspace = {
-- checkThirdParty = false,
-- library = {
-- vim.env.VIMRUNTIME,
-- -- Depending on the usage, you might want to add additional paths here.
-- -- "${3rd}/luv/library"
-- -- "${3rd}/busted/library",
-- },
-- -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- -- library = vim.api.nvim_get_runtime_file("", true)
-- },
-- })
-- end,
-- settings = {
-- Lua = {},
-- },
-- })
-- lspconfig.tsserver.setup({})
--
-- -- Global mappings.
-- -- See `:help vim.diagnostic.*` for documentation on any of the below functions
-- vim.keymap.set("n", "<localleader>e", vim.diagnostic.open_float)
-- vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
-- vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
-- vim.keymap.set("n", "<localleader>q", vim.diagnostic.setloclist)
--
-- -- Use LspAttach autocommand to only map the following keys
-- -- after the language server attaches to the current buffer
-- vim.api.nvim_create_autocmd("LspAttach", {
-- group = vim.api.nvim_create_augroup("UserLspConfig", {}),
-- callback = function(ev)
-- -- Enable completion triggered by <c-x><c-o>
-- vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
--
-- -- Buffer local mappings.
-- -- See `:help vim.lsp.*` for documentation on any of the below functions
-- local opts = { buffer = ev.buf }
-- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
-- vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
-- vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
-- vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
-- vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
-- vim.keymap.set("n", "<localleader>wa", vim.lsp.buf.add_workspace_folder, opts)
-- vim.keymap.set("n", "<localleader>wr", vim.lsp.buf.remove_workspace_folder, opts)
-- vim.keymap.set("n", "<localleader>wl", function()
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
-- end, opts)
-- vim.keymap.set("n", "<localleader>D", vim.lsp.buf.type_definition, opts)
-- vim.keymap.set("n", "<localleader>rn", vim.lsp.buf.rename, opts)
-- vim.keymap.set({ "n", "v" }, "<localleader>ca", vim.lsp.buf.code_action, opts)
-- vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
-- 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,
-- },
-- })
2 changes: 2 additions & 0 deletions nvim/lua/dcp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
require("dcp.set-background")
require("dcp.keymaps")
require("dcp.options")
require("dcp.lsp")
require("dcp.treesitter")
Loading