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 = {
|
||||
-- override lsp server options
|
||||
--[[ rust_analyzer = {
|
||||
opts = {}
|
||||
}, ]]
|
||||
-- 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 = {
|
||||
format = false,
|
||||
},
|
||||
efm = {
|
||||
format = true, -- true or false
|
||||
format = true,
|
||||
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 = {
|
||||
format = false, -- disable formatting all together
|
||||
},
|
||||
|
|
|
@ -1,23 +1,36 @@
|
|||
local map = require('cosmic.utils').map
|
||||
local M = {}
|
||||
|
||||
-- navigation
|
||||
map('n', '<leader>sf', ':Telescope find_files<cr>')
|
||||
map('n', '<leader>sg', ':Telescope git_files<cr>')
|
||||
map('n', '<leader>sk', ':Telescope buffers<cr>')
|
||||
map('n', '<leader>ss', ':Telescope live_grep<cr>')
|
||||
M.project_files = function()
|
||||
local opts = {} -- define here if you want to define something
|
||||
local ok = pcall(require('telescope.builtin').git_files, opts)
|
||||
if not ok then
|
||||
require('telescope.builtin').find_files(opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- git navigation
|
||||
map('n', '<leader>ggc', ':Telescope git_commits<cr>')
|
||||
map('n', '<leader>ggs', ':Telescope git_status<cr>')
|
||||
M.init = function()
|
||||
-- navigation
|
||||
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
|
||||
map('n', '<leader>cp', ':cprev<cr>')
|
||||
map('n', '<leader>cn', ':cnext<cr>')
|
||||
-- git navigation
|
||||
map('n', '<leader>ggc', ':Telescope git_commits<cr>')
|
||||
map('n', '<leader>ggs', ':Telescope git_status<cr>')
|
||||
|
||||
-- buffer navigation
|
||||
map('n', '<leader>bp', ':bprev<cr>')
|
||||
map('n', '<leader>bn', ':bnext<cr>')
|
||||
-- quickfix navigation
|
||||
map('n', '<leader>cp', ':cprev<cr>')
|
||||
map('n', '<leader>cn', ':cnext<cr>')
|
||||
|
||||
-- tab navigation
|
||||
map('n', '<leader>tp', ':tprev<cr>')
|
||||
map('n', '<leader>tn', ':tnext<cr>')
|
||||
-- buffer navigation
|
||||
map('n', '<leader>bp', ':bprev<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 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 = {
|
||||
Error = icons.error .. ' ',
|
||||
Warn = icons.warn .. ' ',
|
||||
|
@ -20,9 +18,9 @@ function M.init()
|
|||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function do_legacy_diagnostic_signs()
|
||||
local function do_legacy_diagnostic_signs()
|
||||
local signs = {
|
||||
Error = icons.error .. ' ',
|
||||
Warning = icons.warn .. ' ',
|
||||
|
@ -36,10 +34,7 @@ function M.init()
|
|||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do_diagnostic_signs()
|
||||
do_legacy_diagnostic_signs()
|
||||
end
|
||||
|
||||
return M
|
||||
do_diagnostic_signs()
|
||||
do_legacy_diagnostic_signs()
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
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/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = 'single',
|
||||
})
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ map('n', '<leader>cf', ':cfdo %s/')
|
|||
-- make Y behave like others
|
||||
map('n', 'Y', 'y$')
|
||||
|
||||
require('cosmic.core.navigation.mappings')
|
||||
require('cosmic.core.navigation.mappings').init()
|
||||
require('cosmic.core.file-explorer.mappings')
|
||||
require('cosmic.core.terminal.mappings')
|
||||
require('cosmic.lsp.mappings')
|
||||
|
|
Loading…
Add table
Reference in a new issue