Skip to content

Commit

Permalink
fix(vim): allow for project-specific config files
Browse files Browse the repository at this point in the history
  • Loading branch information
mscharley committed Sep 28, 2024
1 parent 842f551 commit 04265d5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
4 changes: 4 additions & 0 deletions xdg-config/nvim%init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vim.opt.showtabline = 2
vim.opt.title = true

-- Tab/whitespace configuration
vim.opt.expandtab = false
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
Expand All @@ -24,6 +25,9 @@ vim.opt.list = true
vim.opt.backup = true
vim.opt.backupdir = vim.env.XDG_DATA_HOME .. "/nvim/backup"

-- Allow project-specific settings
vim.opt.exrc = true

-- Load vim-plug
local Plug = require('usermod.vimplug')

Expand Down
54 changes: 27 additions & 27 deletions xdg-config/nvim%lua%usermod/plugins/nvim-lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ require('usermod.vimplug')('neovim/nvim-lspconfig', {
})
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = { Lua = {} },
on_init = function(client)
-- Helper to load the VIM runtimes when editing lua files
if client.workspace_folders then
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
settings = { Lua = { } },
on_init = function(client)
-- Helper to load the VIM runtimes when editing lua files
if client.workspace_folders then
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
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)
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",
}
})
end,
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
}
})
end,
})
lspconfig.jsonls.setup({
capabilities = capabilities,
Expand Down
2 changes: 1 addition & 1 deletion xdg-config/nvim%lua%usermod/plugins/nvim-treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require('usermod.vimplug')('nvim-treesitter/nvim-treesitter', {
require('nvim-treesitter.configs').setup({
ensure_installed = {
"yaml", "json", "json5", "markdown", "toml",
"lua", "vim",
"lua", "vim", "vimdoc",
"perl",
"javascript", "typescript",
"gleam", "rust"
Expand Down

0 comments on commit 04265d5

Please sign in to comment.