diff --git a/lua/cosmic/config/init.lua b/lua/cosmic/config/init.lua index 8a7af40..620d706 100644 --- a/lua/cosmic/config/init.lua +++ b/lua/cosmic/config/init.lua @@ -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 }, diff --git a/lua/cosmic/core/navigation/mappings.lua b/lua/cosmic/core/navigation/mappings.lua index 2810e0d..d98b8c7 100644 --- a/lua/cosmic/core/navigation/mappings.lua +++ b/lua/cosmic/core/navigation/mappings.lua @@ -1,23 +1,36 @@ local map = require('cosmic.utils').map +local M = {} --- navigation -map('n', 'sf', ':Telescope find_files') -map('n', 'sg', ':Telescope git_files') -map('n', 'sk', ':Telescope buffers') -map('n', 'ss', ':Telescope live_grep') +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', 'ggc', ':Telescope git_commits') -map('n', 'ggs', ':Telescope git_status') +M.init = function() + -- navigation + map('n', 'sf', 'lua require("cosmic.core.navigation.mappings").project_files()') + map('n', 'sp', ':Telescope find_files') + map('n', 'sk', ':Telescope buffers') + map('n', 'ss', ':Telescope live_grep') --- quickfix navigation -map('n', 'cp', ':cprev') -map('n', 'cn', ':cnext') + -- git navigation + map('n', 'ggc', ':Telescope git_commits') + map('n', 'ggs', ':Telescope git_status') --- buffer navigation -map('n', 'bp', ':bprev') -map('n', 'bn', ':bnext') + -- quickfix navigation + map('n', 'cp', ':cprev') + map('n', 'cn', ':cnext') --- tab navigation -map('n', 'tp', ':tprev') -map('n', 'tn', ':tnext') + -- buffer navigation + map('n', 'bp', ':bprev') + map('n', 'bn', ':bnext') + + -- tab navigation + map('n', 'tp', ':tprev') + map('n', 'tn', ':tnext') +end + +return M diff --git a/lua/cosmic/lsp/diagnostics.lua b/lua/cosmic/lsp/diagnostics.lua index 3fb0e17..0add56e 100644 --- a/lua/cosmic/lsp/diagnostics.lua +++ b/lua/cosmic/lsp/diagnostics.lua @@ -1,45 +1,40 @@ 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 signs = { - Error = icons.error .. ' ', - Warn = icons.warn .. ' ', - Hint = icons.hint .. ' ', - Info = icons.info .. ' ', - } +local function do_diagnostic_signs() + local signs = { + Error = icons.error .. ' ', + Warn = icons.warn .. ' ', + Hint = icons.hint .. ' ', + Info = icons.info .. ' ', + } - local t = vim.fn.sign_getdefined('DiagnosticSignWarn') - if vim.tbl_isempty(t) then - for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) - end + local t = vim.fn.sign_getdefined('DiagnosticSignWarn') + if vim.tbl_isempty(t) then + for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) end end - - local function do_legacy_diagnostic_signs() - local signs = { - Error = icons.error .. ' ', - Warning = icons.warn .. ' ', - Hint = icons.hint .. ' ', - Information = icons.info .. ' ', - } - local h = vim.fn.sign_getdefined('LspDiagnosticsSignWarn') - if vim.tbl_isempty(h) then - for type, icon in pairs(signs) do - local hl = 'LspDiagnosticsSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) - end - end - end - - do_diagnostic_signs() - do_legacy_diagnostic_signs() end -return M +local function do_legacy_diagnostic_signs() + local signs = { + Error = icons.error .. ' ', + Warning = icons.warn .. ' ', + Hint = icons.hint .. ' ', + Information = icons.info .. ' ', + } + local h = vim.fn.sign_getdefined('LspDiagnosticsSignWarn') + if vim.tbl_isempty(h) then + for type, icon in pairs(signs) do + local hl = 'LspDiagnosticsSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) + end + end +end + +do_diagnostic_signs() +do_legacy_diagnostic_signs() diff --git a/lua/cosmic/lsp/init.lua b/lua/cosmic/lsp/init.lua index 6fc2f10..4905687 100644 --- a/lua/cosmic/lsp/init.lua +++ b/lua/cosmic/lsp/init.lua @@ -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', }) - diff --git a/lua/cosmic/mappings.lua b/lua/cosmic/mappings.lua index f8fdb82..8dd9a59 100644 --- a/lua/cosmic/mappings.lua +++ b/lua/cosmic/mappings.lua @@ -9,7 +9,7 @@ map('n', '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')