From 2534235862adb475e253f9027ff11cb8cf3d74d4 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Fri, 3 Nov 2023 18:39:54 +0900 Subject: [PATCH 1/3] (WIP)nvim: lean: setup lsp and lean.nvim manually --- dotfiles/neovim/init.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 423037f..07562f0 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -130,6 +130,31 @@ require('lazy').setup({ 'folke/trouble.nvim', -- config = function }, + { + 'Julian/lean.nvim', + event = { 'BufReadPre *.lean', 'BufNewFile *.lean' }, + + dependencies = { + 'neovim/nvim-lspconfig', + 'nvim-lua/plenary.nvim', + 'hrsh7th/nvim-cmp', + }, + + -- see Julian/lean.nvim readme + opts = { + lsp = { + on_attach = on_attach, + }, + mappings = true, + }, + + -- this currently disables all default settings in lean.nvim + -- default lean.nvim config overwrites lspconfig + -- TODO: migrate default settings from lean.nvim + config = function () + vim.g.maplocalleader = ' ' + end, + }, }) ----------------------------------------------------------- @@ -540,7 +565,7 @@ lspconfig.powershell_es.setup { -- } local lss = { "pyright", "rust_analyzer", "texlab", "ccls", "clangd", "tsserver", --[["tailwindcss"]] "hls", "cmake", - "csharp_ls", "html", "r_language_server", } + "csharp_ls", "html", "r_language_server", "leanls" } for _, ls in pairs(lss) do lspconfig[ls].setup { on_attach = on_attach, From df4a2e5c20f77c90ce5b2e8c337c3568784901b6 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Wed, 15 Nov 2023 22:34:30 +0900 Subject: [PATCH 2/3] fix: nvim: remove leanls from lspconfig ref: https://github.com/neovim/nvim-lspconfig/wiki/Language-specific-plugins --- dotfiles/neovim/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 07562f0..5e1bdf2 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -565,7 +565,7 @@ lspconfig.powershell_es.setup { -- } local lss = { "pyright", "rust_analyzer", "texlab", "ccls", "clangd", "tsserver", --[["tailwindcss"]] "hls", "cmake", - "csharp_ls", "html", "r_language_server", "leanls" } + "csharp_ls", "html", "r_language_server" } for _, ls in pairs(lss) do lspconfig[ls].setup { on_attach = on_attach, From 31d395449ca27ec01d34b1d85ee90dc3fc2a4f48 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 16 Dec 2023 03:00:24 +0900 Subject: [PATCH 3/3] update: nvim: lean lsp config (copied from main lsp on_attach) --- dotfiles/neovim/init.lua | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index f3f4177..717be7e 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -144,7 +144,29 @@ require('lazy').setup({ -- see Julian/lean.nvim readme opts = { lsp = { - on_attach = on_attach, + on_attach = function(client, bufnr) + -- Enable completion triggered by + --vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings + -- See `:help vim.lsp.*` for documentation on any of the below function + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'g1', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'grf', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + end, }, mappings = true, }, @@ -152,9 +174,6 @@ require('lazy').setup({ -- this currently disables all default settings in lean.nvim -- default lean.nvim config overwrites lspconfig -- TODO: migrate default settings from lean.nvim - config = function () - vim.g.maplocalleader = ' ' - end, }, { 'nvim-orgmode/orgmode', @@ -233,6 +252,7 @@ vim.cmd.colorscheme "catppuccin" ----------------------------------------------------------- vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' -- some terminalmode settings vim.keymap.set('t', 'h', 'h', { noremap = true, desc = "Exit terminal-mode and move to left window." }) @@ -250,7 +270,7 @@ vim.keymap.set('t', 'l', 'l', if vim.fn.has('win32') == 1 then -- this evaluation is so slow that I removed windows powershell support -- if vim.fn.executable('pwsh') == 1 then - vim.opt.shell = 'pwsh' + vim.opt.shell = 'pwsh' -- else -- vim.opt.shell = 'powershell' -- end @@ -347,7 +367,7 @@ require('lualine_setup') -- telescope local builtin = require('telescope.builtin') vim.keymap.set('n', '', function() builtin.find_files { sort_lastused = true } end) -- fd? -vim.keymap.set('n', 'ff', function() builtin.find_files { sort_lastused = true } end, { desc = "find files"}) +vim.keymap.set('n', 'ff', function() builtin.find_files { sort_lastused = true } end, { desc = "find files" }) vim.keymap.set('n', 'fw', builtin.lsp_workspace_symbols, { desc = "lsp workspace symbols" }) vim.keymap.set('n', 'fd', builtin.lsp_document_symbols, { desc = "lsp document symbols" }) vim.keymap.set('n', 'fb', builtin.buffers, { desc = "buffers" })