From 96ff0ce5d6cad6ea3a7f84d79273445f32aff7bd Mon Sep 17 00:00:00 2001 From: spike Date: Tue, 27 Sep 2022 21:42:03 +0200 Subject: [PATCH] WIP per project lsp --- after/plugin/lspAutostart.lua | 30 -------------------- after/plugin/perproject/lsp.lua | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 30 deletions(-) delete mode 100644 after/plugin/lspAutostart.lua create mode 100644 after/plugin/perproject/lsp.lua diff --git a/after/plugin/lspAutostart.lua b/after/plugin/lspAutostart.lua deleted file mode 100644 index 17037d5..0000000 --- a/after/plugin/lspAutostart.lua +++ /dev/null @@ -1,30 +0,0 @@ --- helper module for setting custom lsp settings per project --- will be used for setting autostart of lspclient per projects - -local autocmd = vim.api.nvim_create_autocmd -local augroup = vim.api.nvim_create_augroup - -local augroup_name = "spike_lsp" - -local function per_project_file() - local cwd = vim.fn.getcwd() - -- TODO: - -- check if there is a custom .nvim-lsp file in dir - -- read custom lsp config from file in table format - -- clean merge it ? with local template config to avoid random vars - -- setup local callback functions automatically called if certain settings - -- are present. -end - - -augroup( augroup_name ,{}) -autocmd({"BufReadPre"},{ - group = augroup_name, - pattern = "*", - callback = per_project_file, -}) -autocmd({"DirChanged"},{ - group = augroup_name, - pattern = "window", - callback = per_project_file -}) diff --git a/after/plugin/perproject/lsp.lua b/after/plugin/perproject/lsp.lua new file mode 100644 index 0000000..fb25836 --- /dev/null +++ b/after/plugin/perproject/lsp.lua @@ -0,0 +1,50 @@ +-- helper module for setting custom lsp settings per project +-- will be used for setting autostart of lspclient per projects + + +local ok, Path = pcall(require, "plenary.path") +if not ok then + print("plenary required !") +end +-- local scandir = require("") +local pp = require("spike.perproject") + +local autocmd = vim.api.nvim_create_autocmd +local augroup = vim.api.nvim_create_augroup +local augroup_name = "spike_lsp" +local custom + +local function per_project_file() + local cwd = Path.new(vim.fn.getcwd()) + local pp_dir = cwd:joinpath(pp.base_dirname) + if pp_dir:is_dir() then + print(pp_dir) + else + -- print("no " .. pp.base_dirname) + end + + -- TODO: + -- check if there is a custom .nvim-lsp dir in working dir + -- each file inside .nvim-lsp represent a active option if + -- it is present + -- example + -- workingDir/ + -- .perproject/ + -- lsp.autostart --> autostart lsp for this project +end + +per_project_file() + + +augroup( augroup_name ,{}) -- automatically clears prev group commands +autocmd({"BufReadPre"},{ + group = augroup_name, + pattern = "*", + callback = per_project_file, +}) +autocmd({"DirChanged"},{ + group = augroup_name, + pattern = "window", + callback = per_project_file +}) +