feat(lsp): add lua defaults to config
* feat(mappings): better defaults
This commit is contained in:
parent
0816c008c3
commit
449a50db9a
5 changed files with 94 additions and 62 deletions
|
@ -57,19 +57,44 @@ local default_config = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
servers = {
|
servers = {
|
||||||
-- override lsp server options
|
|
||||||
--[[ rust_analyzer = {
|
|
||||||
opts = {}
|
|
||||||
}, ]]
|
|
||||||
-- enable/disable server + formatting
|
-- enable/disable server + formatting
|
||||||
-- rust_analyzer = true, -- enable non-default servers (todo: support for custom server configs)
|
-- rust_analyzer = true, -- enable non-default servers
|
||||||
|
|
||||||
|
-- or override lsp server options
|
||||||
|
--[[
|
||||||
|
rust_analyzer = {
|
||||||
|
opts = {}
|
||||||
|
},
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- enable, but disable formatting
|
||||||
eslint = {
|
eslint = {
|
||||||
format = false,
|
format = false,
|
||||||
},
|
},
|
||||||
efm = {
|
efm = {
|
||||||
format = true, -- true or false
|
format = true,
|
||||||
disable_formatters = { 'eslint' }, -- e.g. 'eslint', 'prettier', 'stylua'
|
disable_formatters = { 'eslint' }, -- e.g. 'eslint', 'prettier', 'stylua'
|
||||||
},
|
},
|
||||||
|
sumneko_lua = {
|
||||||
|
opts = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
-- Get the language server to recognize the `vim` global
|
||||||
|
globals = { 'vim' },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
-- Make the server aware of Neovim runtime files
|
||||||
|
library = {
|
||||||
|
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
||||||
|
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
|
||||||
|
},
|
||||||
|
maxPreload = 10000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
tsserver = {
|
tsserver = {
|
||||||
format = false, -- disable formatting all together
|
format = false, -- disable formatting all together
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,23 +1,36 @@
|
||||||
local map = require('cosmic.utils').map
|
local map = require('cosmic.utils').map
|
||||||
|
local M = {}
|
||||||
|
|
||||||
-- navigation
|
M.project_files = function()
|
||||||
map('n', '<leader>sf', ':Telescope find_files<cr>')
|
local opts = {} -- define here if you want to define something
|
||||||
map('n', '<leader>sg', ':Telescope git_files<cr>')
|
local ok = pcall(require('telescope.builtin').git_files, opts)
|
||||||
map('n', '<leader>sk', ':Telescope buffers<cr>')
|
if not ok then
|
||||||
map('n', '<leader>ss', ':Telescope live_grep<cr>')
|
require('telescope.builtin').find_files(opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- git navigation
|
M.init = function()
|
||||||
map('n', '<leader>ggc', ':Telescope git_commits<cr>')
|
-- navigation
|
||||||
map('n', '<leader>ggs', ':Telescope git_status<cr>')
|
map('n', '<leader>sf', '<cmd>lua require("cosmic.core.navigation.mappings").project_files()<cr>')
|
||||||
|
map('n', '<leader>sp', ':Telescope find_files<cr>')
|
||||||
|
map('n', '<leader>sk', ':Telescope buffers<cr>')
|
||||||
|
map('n', '<leader>ss', ':Telescope live_grep<cr>')
|
||||||
|
|
||||||
-- quickfix navigation
|
-- git navigation
|
||||||
map('n', '<leader>cp', ':cprev<cr>')
|
map('n', '<leader>ggc', ':Telescope git_commits<cr>')
|
||||||
map('n', '<leader>cn', ':cnext<cr>')
|
map('n', '<leader>ggs', ':Telescope git_status<cr>')
|
||||||
|
|
||||||
-- buffer navigation
|
-- quickfix navigation
|
||||||
map('n', '<leader>bp', ':bprev<cr>')
|
map('n', '<leader>cp', ':cprev<cr>')
|
||||||
map('n', '<leader>bn', ':bnext<cr>')
|
map('n', '<leader>cn', ':cnext<cr>')
|
||||||
|
|
||||||
-- tab navigation
|
-- buffer navigation
|
||||||
map('n', '<leader>tp', ':tprev<cr>')
|
map('n', '<leader>bp', ':bprev<cr>')
|
||||||
map('n', '<leader>tn', ':tnext<cr>')
|
map('n', '<leader>bn', ':bnext<cr>')
|
||||||
|
|
||||||
|
-- tab navigation
|
||||||
|
map('n', '<leader>tp', ':tprev<cr>')
|
||||||
|
map('n', '<leader>tn', ':tnext<cr>')
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
local config = require('cosmic.config')
|
local config = require('cosmic.config')
|
||||||
local icons = require('cosmic.core.theme.icons')
|
local icons = require('cosmic.core.theme.icons')
|
||||||
local M = {}
|
|
||||||
|
|
||||||
function M.init()
|
vim.diagnostic.config(config.lsp.diagnostic)
|
||||||
vim.diagnostic.config(config.lsp.diagnostic)
|
|
||||||
|
|
||||||
local function do_diagnostic_signs()
|
local function do_diagnostic_signs()
|
||||||
local signs = {
|
local signs = {
|
||||||
Error = icons.error .. ' ',
|
Error = icons.error .. ' ',
|
||||||
Warn = icons.warn .. ' ',
|
Warn = icons.warn .. ' ',
|
||||||
|
@ -20,9 +18,9 @@ function M.init()
|
||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_legacy_diagnostic_signs()
|
local function do_legacy_diagnostic_signs()
|
||||||
local signs = {
|
local signs = {
|
||||||
Error = icons.error .. ' ',
|
Error = icons.error .. ' ',
|
||||||
Warning = icons.warn .. ' ',
|
Warning = icons.warn .. ' ',
|
||||||
|
@ -36,10 +34,7 @@ function M.init()
|
||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
do_diagnostic_signs()
|
|
||||||
do_legacy_diagnostic_signs()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
do_diagnostic_signs()
|
||||||
|
do_legacy_diagnostic_signs()
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
require('cosmic.lsp.providers')
|
require('cosmic.lsp.providers')
|
||||||
require('cosmic.lsp.diagnostics').init()
|
require('cosmic.lsp.diagnostics')
|
||||||
|
|
||||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'single' })
|
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'single' })
|
||||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
border = 'single',
|
border = 'single',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ map('n', '<leader>cf', ':cfdo %s/')
|
||||||
-- make Y behave like others
|
-- make Y behave like others
|
||||||
map('n', 'Y', 'y$')
|
map('n', 'Y', 'y$')
|
||||||
|
|
||||||
require('cosmic.core.navigation.mappings')
|
require('cosmic.core.navigation.mappings').init()
|
||||||
require('cosmic.core.file-explorer.mappings')
|
require('cosmic.core.file-explorer.mappings')
|
||||||
require('cosmic.core.terminal.mappings')
|
require('cosmic.core.terminal.mappings')
|
||||||
require('cosmic.lsp.mappings')
|
require('cosmic.lsp.mappings')
|
||||||
|
|
Loading…
Add table
Reference in a new issue