I'm encountering an error similar to xdg-mime-install-does-not-update-files-mime-type-association and why-does-xdg-mime-query-filetype-fail-to-find-a-new-added-file-type
But the solution to the first one is to add some content to the file which does not to work.
And the solution to the second link is not complete since I have xdg-utils installed, And I don't know much about this magic file. I have read man for magic (it refers to /usr/share/file/misc/magic and /usr/share/file/misc/magic.mgc which is not the same as ~/.local/share/mime/magic or /usr/share/mime/magic and it doesn't provide steps to add a filetype to it (I must have missed it or else))
My error still stands even after adding text to that file. To be specific, a .lua file.
Steps I have taken:
- In
~/.local/share/mime/packagesI created a.xmlfile with the following contents,
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="hhttp://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/x-lua">
<comment>Lua scirpt</comment>
<glob-deleteall/>
<glob pattern="*.lua"/>
</mime-type>
</mime-info>
- run
xdg-mime install text-x-lua.xml - run
update-mime-database ~/.local/share/mime - run the following
$ XDG_UTILS_DEBUG_LEVEL=2 xdg-mime default nvim.desktop text/x-lua
make_default_kde: No kde runtime detected
make_default_generic nvim.desktop text/x-lua
Updating /home/boom29/.config/mimeapps.list
$ XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default text/x-lua
Checking /home/boom29/.config/mimeapps.list
nvim.desktop
But these steps do not reflect in practice, xdg-mime filetypes do not update.
For example:
$ cat test.lua
-- defines a factorial function
function fact (n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
print("enter a number:")
a = io.read("*number") -- read a number
print(fact(a))
$ XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query filetype test.lua
Running file --brief --dereference --mime-type "/home/boom29/test.lua"
text/plain
Any help is appreciated.
EDIT:
$ cat init.lua
require("core.keymaps")
$ XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query filetype init.lua
Running file --brief --dereference --mime-type "/home/boom29/.config/nvim/init.lua"
application/javascript
Why is a .lua file being recognized as a javascript file?