diff options
| author | Filip Andrzej Wandzio <dscr@duck.com> | 2024-04-29 21:47:02 +0000 |
|---|---|---|
| committer | Filip Andrzej Wandzio <dscr@duck.com> | 2024-04-29 21:47:02 +0000 |
| commit | 9973865685cbf6524de9d2d74dfa2a0b9c00fb8c (patch) | |
| tree | cbd7455f9859f7cffb633834e3b573885209255a /lua/config/lsp.lua | |
| parent | 354bdafcd6bbc2f6a63ccbf21fb741f41dbd340b (diff) | |
| parent | 00ded90580ba40155adfb90d4f9aab8318140199 (diff) | |
| download | neovim-9973865685cbf6524de9d2d74dfa2a0b9c00fb8c.tar.gz neovim-9973865685cbf6524de9d2d74dfa2a0b9c00fb8c.zip | |
Merge pull request 'test' (#1) from test into master
Reviewed-on: https://codeberg.org/philw/nvim/pulls/1
Diffstat (limited to '')
| -rw-r--r-- | lua/config/lsp.lua | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index ca341d5..7fd0ddb 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua | |||
| @@ -1,64 +1,64 @@ | |||
| 1 | -- local lsp = require('lsp-zero') | 1 | -- local lsp = require('lsp-zero') |
| 2 | 2 | ||
| 3 | local lsp_zero = require("lsp-zero") | 3 | --local lsp_zero = require("lsp-zero") |
| 4 | local cmp = require("cmp") | 4 | --local cmp = require("cmp") |
| 5 | require("luasnip.loaders.from_vscode").lazy_load() | 5 | --require("luasnip.loaders.from_vscode").lazy_load() |
| 6 | 6 | ||
| 7 | lsp_zero.preset("recommended") | 7 | --lsp_zero.preset("recommended") |
| 8 | lsp_zero.setup() | 8 | --lsp_zero.setup() |
| 9 | lsp_zero.on_attach(function(client_id, bufnr) | 9 | --lsp_zero.on_attach(function(client_id, bufnr) |
| 10 | lsp_zero.default_keymaps({ buffer = bufnr }) | 10 | -- lsp_zero.default_keymaps({ buffer = bufnr }) |
| 11 | end) | 11 | --end) |
| 12 | 12 | ||
| 13 | require("mason").setup({}) | 13 | --require("mason").setup({}) |
| 14 | require("mason-lspconfig").setup({ | 14 | --require("mason-lspconfig").setup({ |
| 15 | ensure_installed = { "clangd", "rust_analyzer" }, | 15 | -- ensure_installed = { "clangd", "rust_analyzer" }, |
| 16 | handlers = { | 16 | -- handlers = { |
| 17 | lsp_zero.default_setup, | 17 | -- lsp_zero.default_setup, |
| 18 | }, | 18 | -- }, |
| 19 | }) | 19 | --}) |
| 20 | 20 | ||
| 21 | cmp.setup({ | 21 | --cmp.setup({ |
| 22 | snippet = { | 22 | -- snippet = { |
| 23 | expand = function(args) | 23 | -- expand = function(args) |
| 24 | require("luasnip").lsp_expand(args.body) | 24 | -- require("luasnip").lsp_expand(args.body) |
| 25 | end, | 25 | -- end, |
| 26 | }, | 26 | -- }, |
| 27 | window = {}, | 27 | -- window = {}, |
| 28 | mapping = cmp.mapping.preset.insert({ | 28 | -- mapping = cmp.mapping.preset.insert({ |
| 29 | ["<C-b>"] = cmp.mapping.scroll_docs(-4), | 29 | -- ["<C-b>"] = cmp.mapping.scroll_docs(-4), |
| 30 | ["<C-f>"] = cmp.mapping.scroll_docs(4), | 30 | -- ["<C-f>"] = cmp.mapping.scroll_docs(4), |
| 31 | ["<C-Space>"] = cmp.mapping.complete(), | 31 | -- ["<C-Space>"] = cmp.mapping.complete(), |
| 32 | ["<C-e>"] = cmp.mapping.abort(), | 32 | -- ["<C-e>"] = cmp.mapping.abort(), |
| 33 | ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | 33 | -- ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. |
| 34 | }), | 34 | -- }), |
| 35 | sources = cmp.config.sources({ | 35 | -- sources = cmp.config.sources({ |
| 36 | { name = "nvim_lsp" }, | 36 | -- { name = "nvim_lsp" }, |
| 37 | { name = "luasnip" }, | 37 | -- { name = "luasnip" }, |
| 38 | }, { | 38 | -- }, { |
| 39 | { name = "buffer" }, | 39 | -- { name = "buffer" }, |
| 40 | }), | 40 | -- }), |
| 41 | }) | 41 | --}) |
| 42 | 42 | ||
| 43 | function PrintDiagnostics(opts, bufnr, line_nr, client_id) | 43 | --function PrintDiagnostics(opts, bufnr, line_nr, client_id) |
| 44 | bufnr = bufnr or 0 | 44 | -- bufnr = bufnr or 0 |
| 45 | line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) | 45 | -- line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) |
| 46 | opts = opts or { ["lnum"] = line_nr } | 46 | -- opts = opts or { ["lnum"] = line_nr } |
| 47 | -- | ||
| 48 | -- local line_diagnostics = vim.diagnostic.get(bufnr, opts) | ||
| 49 | -- if vim.tbl_isempty(line_diagnostics) then | ||
| 50 | -- return | ||
| 51 | -- end | ||
| 52 | -- | ||
| 53 | -- local diagnostic_message = "" | ||
| 54 | -- for i, diagnostic in ipairs(line_diagnostics) do | ||
| 55 | -- diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") | ||
| 56 | -- print(diagnostic_message) | ||
| 57 | -- if i ~= #line_diagnostics then | ||
| 58 | -- diagnostic_message = diagnostic_message .. "\n" | ||
| 59 | -- end | ||
| 60 | -- end | ||
| 61 | -- vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) | ||
| 62 | --end | ||
| 47 | 63 | ||
| 48 | local line_diagnostics = vim.diagnostic.get(bufnr, opts) | 64 | --vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]]) |
| 49 | if vim.tbl_isempty(line_diagnostics) then | ||
| 50 | return | ||
| 51 | end | ||
| 52 | |||
| 53 | local diagnostic_message = "" | ||
| 54 | for i, diagnostic in ipairs(line_diagnostics) do | ||
| 55 | diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") | ||
| 56 | print(diagnostic_message) | ||
| 57 | if i ~= #line_diagnostics then | ||
| 58 | diagnostic_message = diagnostic_message .. "\n" | ||
| 59 | end | ||
| 60 | end | ||
| 61 | vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) | ||
| 62 | end | ||
| 63 | |||
| 64 | vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]]) | ||
