testing regular lsp attach
This commit is contained in:
		
							parent
							
								
									06aeca8dfd
								
							
						
					
					
						commit
						34ed925a02
					
				
							
								
								
									
										168
									
								
								config/init.lua
									
									
									
									
									
								
							
							
						
						
									
										168
									
								
								config/init.lua
									
									
									
									
									
								
							@ -51,10 +51,88 @@ local lspconfig = require('lspconfig')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
vim.o.updatetime = 250
 | 
					vim.o.updatetime = 250
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local on_attach = function(_, bufnr)
 | 
					-- local on_attach = function(client, bufnr)
 | 
				
			||||||
 | 
					--     -- key mappings
 | 
				
			||||||
 | 
					--     local opts = {
 | 
				
			||||||
 | 
					--         buffer = bufnr,
 | 
				
			||||||
 | 
					--         noremap = true,
 | 
				
			||||||
 | 
					--         focusable = false,
 | 
				
			||||||
 | 
					--         border = 'rounded',
 | 
				
			||||||
 | 
					--         source = 'always',
 | 
				
			||||||
 | 
					--         prefix = ' ',
 | 
				
			||||||
 | 
					--         scope = 'cursor',
 | 
				
			||||||
 | 
					--         close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
 | 
				
			||||||
 | 
					--     }
 | 
				
			||||||
 | 
					--     -- error viewing
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
 | 
				
			||||||
 | 
					--     -- def viewing/rename
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
 | 
				
			||||||
 | 
					--     vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
 | 
				
			||||||
 | 
					--     -- auto hover for error viewing
 | 
				
			||||||
 | 
					--     vim.api.nvim_create_autocmd("CursorHold", {
 | 
				
			||||||
 | 
					--         callback = function()
 | 
				
			||||||
 | 
					--             vim.diagnostic.open_float(nil, opts)
 | 
				
			||||||
 | 
					--         end
 | 
				
			||||||
 | 
					--     })
 | 
				
			||||||
 | 
					-- end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Go
 | 
				
			||||||
 | 
					lspconfig.gopls.setup{
 | 
				
			||||||
 | 
					    cmd = {"gopls", "serve"},
 | 
				
			||||||
 | 
					    filetypes = {"go", "gomod"},
 | 
				
			||||||
 | 
					    settings = {
 | 
				
			||||||
 | 
					        gopls = {
 | 
				
			||||||
 | 
					            analyses = {
 | 
				
			||||||
 | 
					                unusedparams = true,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            staticcheck = true,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- C/C++
 | 
				
			||||||
 | 
					lspconfig.clangd.setup{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Lua
 | 
				
			||||||
 | 
					lspconfig.lua_ls.setup{
 | 
				
			||||||
 | 
					    settings = {
 | 
				
			||||||
 | 
					        Lua = {
 | 
				
			||||||
 | 
					            diagnostics = {globals = {'vim', 'opts'}},
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        telemetry = {
 | 
				
			||||||
 | 
					            enable = false,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Rust
 | 
				
			||||||
 | 
					lspconfig.rust_analyzer.setup{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Python
 | 
				
			||||||
 | 
					lspconfig.pylsp.setup{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- TypeScript
 | 
				
			||||||
 | 
					lspconfig.tsserver.setup{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Fix virtual text going off screen
 | 
				
			||||||
 | 
					vim.diagnostic.config({
 | 
				
			||||||
 | 
					    virtual_text = false,
 | 
				
			||||||
 | 
					    signs = true,
 | 
				
			||||||
 | 
					    underline = true,
 | 
				
			||||||
 | 
					    update_in_insert = false,
 | 
				
			||||||
 | 
					    severity_sort = false,
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					vim.api.nvim_create_autocmd('LspAttach', {
 | 
				
			||||||
 | 
					    callback = function(ev)
 | 
				
			||||||
        -- key mappings
 | 
					        -- key mappings
 | 
				
			||||||
        local opts = {
 | 
					        local opts = {
 | 
				
			||||||
        buffer = bufnr,
 | 
					            buffer = ev.buf,
 | 
				
			||||||
            noremap = true,
 | 
					            noremap = true,
 | 
				
			||||||
            focusable = false,
 | 
					            focusable = false,
 | 
				
			||||||
            border = 'rounded',
 | 
					            border = 'rounded',
 | 
				
			||||||
@ -78,79 +156,15 @@ local on_attach = function(_, bufnr)
 | 
				
			|||||||
                vim.diagnostic.open_float(nil, opts)
 | 
					                vim.diagnostic.open_float(nil, opts)
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
end
 | 
					        -- local opts = { buffer = ev.buf }
 | 
				
			||||||
 | 
					        -- -- error viewing
 | 
				
			||||||
-- Go
 | 
					        -- vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
 | 
				
			||||||
lspconfig.gopls.setup{
 | 
					        -- vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
 | 
				
			||||||
    cmd = {"gopls", "serve"},
 | 
					        -- vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
 | 
				
			||||||
    on_attach = on_attach,
 | 
					        -- -- def viewing/rename
 | 
				
			||||||
    filetypes = {"go", "gomod"},
 | 
					        -- vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
 | 
				
			||||||
    settings = {
 | 
					        -- vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
 | 
				
			||||||
        gopls = {
 | 
					        -- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
 | 
				
			||||||
            analyses = {
 | 
					        -- vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
 | 
				
			||||||
                unusedparams = true,
 | 
					    end,
 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            staticcheck = true,
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- C/C++
 | 
					 | 
				
			||||||
lspconfig.clangd.setup{
 | 
					 | 
				
			||||||
    on_attach = on_attach,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Lua
 | 
					 | 
				
			||||||
lspconfig.lua_ls.setup{
 | 
					 | 
				
			||||||
    on_attach = on_attach,
 | 
					 | 
				
			||||||
    settings = {
 | 
					 | 
				
			||||||
        Lua = {
 | 
					 | 
				
			||||||
            diagnostics = {globals = {'vim', 'opts'}},
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        telemetry = {
 | 
					 | 
				
			||||||
            enable = false,
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Rust
 | 
					 | 
				
			||||||
lspconfig.rust_analyzer.setup{
 | 
					 | 
				
			||||||
    on_attach = on_attach,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Python
 | 
					 | 
				
			||||||
lspconfig.pylsp.setup{
 | 
					 | 
				
			||||||
    on_attach = on_attach,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- TypeScript
 | 
					 | 
				
			||||||
lspconfig.tsserver.setup{
 | 
					 | 
				
			||||||
    on_attach = on_attach,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Fix virtual text going off screen
 | 
					 | 
				
			||||||
vim.diagnostic.config({
 | 
					 | 
				
			||||||
    virtual_text = false,
 | 
					 | 
				
			||||||
    signs = true,
 | 
					 | 
				
			||||||
    underline = true,
 | 
					 | 
				
			||||||
    update_in_insert = false,
 | 
					 | 
				
			||||||
    severity_sort = false,
 | 
					 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- vim.api.nvim_create_autocmd('LspAttach', {
 | 
					 | 
				
			||||||
--     callback = function(ev)
 | 
					 | 
				
			||||||
--         local opts = { buffer = ev.buf }
 | 
					 | 
				
			||||||
--         -- error viewing
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
 | 
					 | 
				
			||||||
--         -- def viewing/rename
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
 | 
					 | 
				
			||||||
--         vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
 | 
					 | 
				
			||||||
--     end,
 | 
					 | 
				
			||||||
-- })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user